Skip to content

Commit 3b69912

Browse files
authored
Fix remote project matching by scheme+authority (Closes #927)
1 parent e83f059 commit 3b69912

2 files changed

Lines changed: 36 additions & 2 deletions

File tree

src/storage/storage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export class ProjectStorage {
104104
if (!isRemotePath(element.rootPath)) { continue; }
105105

106106
const uriElement = Uri.parse(element.rootPath);
107-
if (uriElement.path === uri.path) {
107+
if (uriElement.scheme === uri.scheme && uriElement.authority === uri.authority && uriElement.path === uri.path) {
108108
return element;
109109
}
110110
}

src/test/suite/storage.test.ts

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,11 +226,45 @@ suite("ProjectStorage", () => {
226226
const uri = Uri.parse(remoteRoot);
227227
const found = storage.existsRemoteWithRootPath(uri);
228228

229-
// Implementation matches by path, not full URI
230229
assert.ok(found);
231230
assert.strictEqual(found!.name, "RemoteProject");
232231
});
233232

233+
test("existsRemoteWithRootPath uses the remote URI authority when matching", () => {
234+
const filename = createTempFilename();
235+
const storage = new ProjectStorage(filename);
236+
237+
storage.push("RemoteA", "vscode-remote://ssh-remote+server-A/home/user/project");
238+
storage.push("RemoteB", "vscode-remote://ssh-remote+server-B/home/user/project");
239+
240+
const found = storage.existsRemoteWithRootPath(Uri.parse("vscode-remote://ssh-remote+server-B/home/user/project"));
241+
242+
assert.ok(found);
243+
assert.strictEqual(found!.name, "RemoteB");
244+
});
245+
246+
test("existsRemoteWithRootPath ignores same path on a different remote authority", () => {
247+
const filename = createTempFilename();
248+
const storage = new ProjectStorage(filename);
249+
250+
storage.push("RemoteA", "vscode-remote://ssh-remote+server-A/home/user/project");
251+
252+
const found = storage.existsRemoteWithRootPath(Uri.parse("vscode-remote://ssh-remote+server-B/home/user/project"));
253+
254+
assert.strictEqual(found, undefined);
255+
});
256+
257+
test("existsRemoteWithRootPath ignores same authority and path on a different URI scheme", () => {
258+
const filename = createTempFilename();
259+
const storage = new ProjectStorage(filename);
260+
261+
storage.push("RemoteProject", "vscode-remote://ssh-remote+server/home/user/project");
262+
263+
const found = storage.existsRemoteWithRootPath(Uri.parse("vscode-vfs://ssh-remote+server/home/user/project"));
264+
265+
assert.strictEqual(found, undefined);
266+
});
267+
234268
test("existsWithRootPath returns expandedHomePath when asked", () => {
235269
const filename = createTempFilename();
236270
const storage = new ProjectStorage(filename);

0 commit comments

Comments
 (0)