Skip to content

Commit df635b5

Browse files
Merge pull request #2081 from anglox/fix/improve-windows-compatibility
fix(open-in-apps): Improve Windows compatibility and command handling
2 parents 17dcb95 + db966ab commit df635b5

4 files changed

Lines changed: 27 additions & 13 deletions

File tree

src/main/core/app/service.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ class AppService implements IInitializable, IDisposable {
247247

248248
const { host, username, port } = connection;
249249

250-
if (appId === 'vscode' || appId === 'vscodium' || appId === 'cursor') {
250+
if (appId === 'vscode' || appId === 'vscodium' || appId === 'cursor' || appId === 'zed') {
251251
await shell.openExternal(buildRemoteEditorUrl(appId, host, username, target));
252252
return;
253253
}
@@ -390,7 +390,8 @@ class AppService implements IInitializable, IDisposable {
390390
);
391391
}
392392

393-
const quoted = (p: string) => `'${p.replace(/'/g, "'\\''")}'`;
393+
const quoted = (p: string) =>
394+
process.platform !== 'win32' ? `'${p.replace(/'/g, "'\\''")}'` : `"${p.replace(/"/g, '""')}"`;
394395
const commands: string[] = platformConfig?.openCommands ?? [];
395396
const command = commands
396397
.map((cmd) => cmd.replace('{{path}}', quoted(target)).replace('{{path_raw}}', target))

src/main/core/app/utils.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,9 @@ export const resolveAppVersion = async (): Promise<string> => {
176176

177177
export const checkCommand = (cmd: string): Promise<boolean> =>
178178
new Promise((resolve) => {
179-
exec(`command -v ${cmd} >/dev/null 2>&1`, { env: buildExternalToolEnv() }, (error) => {
179+
const check =
180+
process.platform !== 'win32' ? `command -v ${cmd} >/dev/null 2>&1` : `where ${cmd}`;
181+
exec(check, { env: buildExternalToolEnv() }, (error) => {
180182
resolve(!error);
181183
});
182184
});

src/main/utils/remoteOpenIn.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { quoteShellArg } from './shellEscape';
22

3-
type RemoteEditorScheme = 'vscode' | 'vscodium' | 'cursor';
3+
type RemoteEditorScheme = 'vscode' | 'vscodium' | 'cursor' | 'zed';
44

55
export function buildRemoteSshAuthority(host: string, username: string): string {
66
const normalizedHost = host.trim();
@@ -24,7 +24,13 @@ export function buildRemoteEditorUrl(
2424
const authority = buildRemoteSshAuthority(host, username);
2525
const encodedAuthority = encodeURIComponent(authority);
2626
const normalizedTargetPath = targetPath.startsWith('/') ? targetPath : `/${targetPath}`;
27-
return `${scheme}://vscode-remote/ssh-remote+${encodedAuthority}${normalizedTargetPath}`;
27+
28+
switch (scheme) {
29+
case 'zed':
30+
return `zed://ssh/${encodedAuthority}${normalizedTargetPath}`;
31+
default:
32+
return `${scheme}://vscode-remote/ssh-remote+${encodedAuthority}${normalizedTargetPath}`;
33+
}
2834
}
2935

3036
type RemoteTerminalExecInput = {

src/shared/openInApps.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ const _OPEN_IN_APPS = {
9191
appNames: ['Cursor'],
9292
},
9393
win32: {
94-
openCommands: ['start "" cursor {{path}}'],
94+
openCommands: ['cursor {{path}}'],
9595
checkCommands: ['cursor'],
9696
},
9797
linux: {
@@ -118,7 +118,7 @@ const _OPEN_IN_APPS = {
118118
appNames: ['Visual Studio Code'],
119119
},
120120
win32: {
121-
openCommands: ['start "" code {{path}}', 'start "" code-insiders {{path}}'],
121+
openCommands: ['code {{path}}', 'code-insiders {{path}}'],
122122
checkCommands: ['code', 'code-insiders'],
123123
},
124124
linux: {
@@ -145,7 +145,7 @@ const _OPEN_IN_APPS = {
145145
appNames: ['VSCodium'],
146146
},
147147
win32: {
148-
openCommands: ['start "" codium {{path}}'],
148+
openCommands: ['codium {{path}}'],
149149
checkCommands: ['codium'],
150150
},
151151
linux: {
@@ -171,7 +171,7 @@ const _OPEN_IN_APPS = {
171171
appNames: ['Windsurf'],
172172
},
173173
win32: {
174-
openCommands: ['start "" windsurf {{path}}'],
174+
openCommands: ['windsurf {{path}}'],
175175
checkCommands: ['windsurf'],
176176
},
177177
linux: {
@@ -343,6 +343,7 @@ const _OPEN_IN_APPS = {
343343
label: 'Zed',
344344
iconPath: ICON_PATHS.zed,
345345
autoInstall: true,
346+
supportsRemote: true,
346347
platforms: {
347348
darwin: {
348349
openCommands: ['command -v zed >/dev/null 2>&1 && zed {{path}}', 'open -a "Zed" {{path}}'],
@@ -353,6 +354,10 @@ const _OPEN_IN_APPS = {
353354
openCommands: ['zed {{path}}', 'xdg-open {{path}}'],
354355
checkCommands: ['zed'],
355356
},
357+
win32: {
358+
openCommands: ['zed {{path}}'],
359+
checkCommands: ['zed'],
360+
},
356361
},
357362
},
358363
kiro: {
@@ -371,7 +376,7 @@ const _OPEN_IN_APPS = {
371376
appNames: ['Kiro'],
372377
},
373378
win32: {
374-
openCommands: ['start "" kiro {{path}}'],
379+
openCommands: ['kiro {{path}}'],
375380
checkCommands: ['kiro'],
376381
},
377382
linux: {
@@ -395,7 +400,7 @@ const _OPEN_IN_APPS = {
395400
appNames: ['Antigravity'],
396401
},
397402
win32: {
398-
openCommands: ['start "" antigravity {{path}}'],
403+
openCommands: ['antigravity {{path}}'],
399404
checkCommands: ['antigravity'],
400405
},
401406
linux: {
@@ -419,7 +424,7 @@ const _OPEN_IN_APPS = {
419424
appNames: ['Trae'],
420425
},
421426
win32: {
422-
openCommands: ['start "" trae "{{path_raw}}"'],
427+
openCommands: ['trae "{{path_raw}}"'],
423428
checkCommands: ['trae'],
424429
},
425430
linux: {
@@ -443,7 +448,7 @@ const _OPEN_IN_APPS = {
443448
appNames: ['Trae Solo'],
444449
},
445450
win32: {
446-
openCommands: ['start "" trae-solo "{{path_raw}}"'],
451+
openCommands: ['trae-solo "{{path_raw}}"'],
447452
checkCommands: ['trae-solo'],
448453
},
449454
linux: {

0 commit comments

Comments
 (0)