Skip to content

Commit 3f993c9

Browse files
committed
fix: quote args in launchDetached on Windows to support paths with spaces
On Windows, `launchDetached` uses `shell: true` so that editor commands are resolved via PATH. However, when the shell parses the concatenated command string, spaces in file paths are treated as argument separators. This causes "Open in Editor" to open one tab per word in the path instead of opening the project folder. Wrap each argument in double quotes on Windows before passing to `spawn()` so the shell keeps paths intact. Fixes #1804
1 parent afc3924 commit 3f993c9

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

‎apps/server/src/open.ts‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -293,11 +293,16 @@ export const launchDetached = (launch: EditorLaunch) =>
293293
yield* Effect.callback<void, OpenError>((resume) => {
294294
let child;
295295
try {
296-
child = spawn(launch.command, [...launch.args], {
297-
detached: true,
298-
stdio: "ignore",
299-
shell: process.platform === "win32",
300-
});
296+
const isWin32 = process.platform === "win32";
297+
child = spawn(
298+
launch.command,
299+
isWin32 ? launch.args.map((a) => `"${a}"`) : [...launch.args],
300+
{
301+
detached: true,
302+
stdio: "ignore",
303+
shell: isWin32,
304+
},
305+
);
301306
} catch (error) {
302307
return resume(
303308
Effect.fail(new OpenError({ message: "failed to spawn detached process", cause: error })),

0 commit comments

Comments
 (0)