Skip to content

Commit ba916a7

Browse files
maria-rcksclaude
andcommitted
fix(editors): only strip the drive when the Zed path came from Windows
A POSIX directory literally named /C:/project must not be rewritten. Co-Authored-By: Claude Fable 5.1 <[email protected]>
1 parent 82a2514 commit ba916a7

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

‎apps/web/src/remoteOpen.test.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,9 @@ describe("buildRemoteOpenUrl", () => {
155155
expect(
156156
buildRemoteOpenUrl({ editor: "zed", host: "sol", absolutePath: "C:\\Users\\theo" }),
157157
).toBe("zed://ssh/sol/Users/theo");
158+
expect(buildRemoteOpenUrl({ editor: "zed", host: "sol", absolutePath: "/C:/project" })).toBe(
159+
"zed://ssh/sol/C%3A/project",
160+
);
158161
});
159162

160163
it("returns undefined for editors without remote support", () => {

‎packages/contracts/src/editor.ts‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,12 @@ export const buildRemoteOpenUrl = (input: {
122122
const encodedHost = encodeURIComponent(input.host);
123123
if (input.editor === "zed") {
124124
// Zed's remote server resolves a rooted path on the system drive, so a
125-
// Windows `/C:/Users/x` must become `/Users/x` (verified in #8938). Other
126-
// drives are untested and kept as is rather than silently remapped.
127-
const zedPath = rootedPath.replace(/^\/[Cc]:(?=\/|$)/, "");
125+
// Windows `C:\Users\x` must become `/Users/x` (verified in #8938). Other
126+
// drives are untested and kept as is rather than silently remapped, and a
127+
// POSIX path that happens to start with `/C:` is left alone.
128+
const zedPath = /^[Cc]:[\\/]/.test(input.absolutePath) ? rootedPath.slice(3) : rootedPath;
128129
const encodedZedPath = zedPath.split("/").map(encodeURIComponent).join("/");
129-
return `${scheme}://ssh/${encodedHost}${encodedZedPath || "/"}`;
130+
return `${scheme}://ssh/${encodedHost}${encodedZedPath}`;
130131
}
131132
const encodedPath = rootedPath.split("/").map(encodeURIComponent).join("/");
132133
return `${scheme}://vscode-remote/ssh-remote+${encodedHost}${encodedPath}`;

0 commit comments

Comments
 (0)