Skip to content

Commit ac6347e

Browse files
committed
feature: supports to use Zed as external editor on Windows (#1852)
Signed-off-by: leo <longshuang@msn.cn>
1 parent 4796234 commit ac6347e

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ This app supports open repository in external tools listed in the table below.
155155
| Cursor | YES | YES | YES |
156156
| Fleet | YES | YES | YES |
157157
| Sublime Text | YES | YES | YES |
158-
| Zed | NO | YES | YES |
158+
| Zed | YES | YES | YES |
159159
| Visual Studio | YES | NO | NO |
160160

161161
> [!NOTE]

src/Native/Windows.cs

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,11 @@ public string FindTerminal(Models.ShellOrTerminal shell)
187187
finder.VSCode(FindVSCode);
188188
finder.VSCodeInsiders(FindVSCodeInsiders);
189189
finder.VSCodium(FindVSCodium);
190-
finder.Cursor(FindCursor);
190+
finder.Cursor(() => Path.Combine(localAppDataDir, @"Programs\Cursor\Cursor.exe"));
191191
finder.Fleet(() => Path.Combine(localAppDataDir, @"Programs\Fleet\Fleet.exe"));
192192
finder.FindJetBrainsFromToolbox(() => Path.Combine(localAppDataDir, @"JetBrains\Toolbox"));
193193
finder.SublimeText(FindSublimeText);
194+
finder.Zed(() => FindZed(localAppDataDir));
194195
FindVisualStudio(finder);
195196
return finder.Tools;
196197
}
@@ -415,16 +416,20 @@ private void FindVisualStudio(Models.ExternalToolsFinder finder)
415416
}
416417
}
417418

418-
private string FindCursor()
419+
private string FindZed(string localAppDataDir)
419420
{
420-
var cursorPath = Path.Combine(
421-
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
422-
"Programs",
423-
"Cursor",
424-
"Cursor.exe");
425-
426-
if (File.Exists(cursorPath))
427-
return cursorPath;
421+
var currentUser = Microsoft.Win32.RegistryKey.OpenBaseKey(
422+
Microsoft.Win32.RegistryHive.CurrentUser,
423+
Microsoft.Win32.RegistryView.Registry64);
424+
425+
// NOTE: this is the official Zed Preview reg data.
426+
var preview = currentUser.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{F70E4811-D0E2-4D88-AC99-D63752799F95}_is1");
427+
if (preview != null)
428+
return preview.GetValue("DisplayIcon") as string;
429+
430+
var findInPath = new StringBuilder("zed.exe", 512);
431+
if (PathFindOnPath(findInPath, null))
432+
return findInPath.ToString();
428433

429434
return string.Empty;
430435
}

0 commit comments

Comments
 (0)