feature: supports to use Zed as external editor on Windows (#1852)

Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
leo
2025-10-14 18:02:10 +08:00
parent 47962340bc
commit ac6347ed4b
2 changed files with 15 additions and 10 deletions

View File

@@ -155,7 +155,7 @@ This app supports open repository in external tools listed in the table below.
| Cursor | YES | YES | YES |
| Fleet | YES | YES | YES |
| Sublime Text | YES | YES | YES |
| Zed | NO | YES | YES |
| Zed | YES | YES | YES |
| Visual Studio | YES | NO | NO |
> [!NOTE]

View File

@@ -187,10 +187,11 @@ namespace SourceGit.Native
finder.VSCode(FindVSCode);
finder.VSCodeInsiders(FindVSCodeInsiders);
finder.VSCodium(FindVSCodium);
finder.Cursor(FindCursor);
finder.Cursor(() => Path.Combine(localAppDataDir, @"Programs\Cursor\Cursor.exe"));
finder.Fleet(() => Path.Combine(localAppDataDir, @"Programs\Fleet\Fleet.exe"));
finder.FindJetBrainsFromToolbox(() => Path.Combine(localAppDataDir, @"JetBrains\Toolbox"));
finder.SublimeText(FindSublimeText);
finder.Zed(() => FindZed(localAppDataDir));
FindVisualStudio(finder);
return finder.Tools;
}
@@ -415,16 +416,20 @@ namespace SourceGit.Native
}
}
private string FindCursor()
private string FindZed(string localAppDataDir)
{
var cursorPath = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
"Programs",
"Cursor",
"Cursor.exe");
var currentUser = Microsoft.Win32.RegistryKey.OpenBaseKey(
Microsoft.Win32.RegistryHive.CurrentUser,
Microsoft.Win32.RegistryView.Registry64);
if (File.Exists(cursorPath))
return cursorPath;
// NOTE: this is the official Zed Preview reg data.
var preview = currentUser.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{F70E4811-D0E2-4D88-AC99-D63752799F95}_is1");
if (preview != null)
return preview.GetValue("DisplayIcon") as string;
var findInPath = new StringBuilder("zed.exe", 512);
if (PathFindOnPath(findInPath, null))
return findInPath.ToString();
return string.Empty;
}