Check for zeditor if zed binary is not found (#3680)

Co-authored-by: Jacob Richman <jacob314@gmail.com>
Co-authored-by: Scott Densmore <scottdensmore@mac.com>
This commit is contained in:
Cole Miller
2025-07-20 15:35:21 -04:00
committed by GitHub
parent 8f85ac7de0
commit 7a9821607b
2 changed files with 178 additions and 46 deletions

View File

@@ -44,21 +44,28 @@ function commandExists(cmd: string): boolean {
}
}
const editorCommands: Record<EditorType, { win32: string; default: string }> = {
vscode: { win32: 'code.cmd', default: 'code' },
vscodium: { win32: 'codium.cmd', default: 'codium' },
windsurf: { win32: 'windsurf', default: 'windsurf' },
cursor: { win32: 'cursor', default: 'cursor' },
vim: { win32: 'vim', default: 'vim' },
neovim: { win32: 'nvim', default: 'nvim' },
zed: { win32: 'zed', default: 'zed' },
/**
* Editor command configurations for different platforms.
* Each editor can have multiple possible command names, listed in order of preference.
*/
const editorCommands: Record<
EditorType,
{ win32: string[]; default: string[] }
> = {
vscode: { win32: ['code.cmd'], default: ['code'] },
vscodium: { win32: ['codium.cmd'], default: ['codium'] },
windsurf: { win32: ['windsurf'], default: ['windsurf'] },
cursor: { win32: ['cursor'], default: ['cursor'] },
vim: { win32: ['vim'], default: ['vim'] },
neovim: { win32: ['nvim'], default: ['nvim'] },
zed: { win32: ['zed'], default: ['zed', 'zeditor'] },
};
export function checkHasEditorType(editor: EditorType): boolean {
const commandConfig = editorCommands[editor];
const command =
const commands =
process.platform === 'win32' ? commandConfig.win32 : commandConfig.default;
return commandExists(command);
return commands.some((cmd) => commandExists(cmd));
}
export function allowEditorTypeInSandbox(editor: EditorType): boolean {
@@ -92,8 +99,12 @@ export function getDiffCommand(
return null;
}
const commandConfig = editorCommands[editor];
const command =
const commands =
process.platform === 'win32' ? commandConfig.win32 : commandConfig.default;
const command =
commands.slice(0, -1).find((cmd) => commandExists(cmd)) ||
commands[commands.length - 1];
switch (editor) {
case 'vscode':
case 'vscodium':