diff --git a/src/features/build-tools/versionCatalog.ts b/src/features/build-tools/versionCatalog.ts index 803ad38017..c2b33b0833 100644 --- a/src/features/build-tools/versionCatalog.ts +++ b/src/features/build-tools/versionCatalog.ts @@ -115,7 +115,8 @@ export function declaredCatalogs(settings: string): DeclaredCatalog[] { } const readText = (path: string) => call(commands.fsReadText(path)).catch(() => null); -const join = (dir: string, rel: string) => (rel.startsWith("/") ? rel : `${dir}/${rel.replace(/^\.\//, "")}`); +const join = (dir: string, rel: string) => + rel.startsWith("/") || /^[A-Za-z]:[\\/]/.test(rel) ? rel : `${dir}/${rel.replace(/^\.\//, "")}`; /** * The catalogs a build script sees: those of the nearest enclosing build (its settings file). diff --git a/src/features/search/__tests__/findScopes.test.ts b/src/features/search/__tests__/findScopes.test.ts index e4ce3848eb..51e7926ffa 100644 --- a/src/features/search/__tests__/findScopes.test.ts +++ b/src/features/search/__tests__/findScopes.test.ts @@ -41,6 +41,12 @@ describe("Find in Files module and custom scopes", () => { path: "/p/web", }); expect(resolveFindScope({ ...base, scopeTab: "module", module: "" }, inputs)).toEqual({ kind: "project" }); + // A Windows workspace member is a drive-letter path, not one under the first project (#4069). + const windows = { ...inputs, root: "C:/tmp/alpha" }; + expect(resolveFindScope({ ...base, scopeTab: "module", module: "C:/tmp/beta" }, windows)).toEqual({ + kind: "directory", + path: "C:/tmp/beta", + }); }); it("named scopes resolve to file sets, files and custom patterns", () => { diff --git a/src/features/search/find/store.ts b/src/features/search/find/store.ts index eecc00a9f9..b19f9bba9b 100644 --- a/src/features/search/find/store.ts +++ b/src/features/search/find/store.ts @@ -255,9 +255,7 @@ export function resolveFindScope(o: FindOptions, inputs: ScopeInputs): SearchSco if (o.scopeTab === "directory" && o.directory.trim()) return { kind: "directory", path: resolveDirectory(o.directory, root) }; if (o.scopeTab === "module") - return o.module && root - ? { kind: "directory", path: o.module.startsWith("/") ? o.module : `${root}/${o.module}` } - : { kind: "project" }; + return o.module && root ? { kind: "directory", path: resolveDirectory(o.module, root) } : { kind: "project" }; if (o.scopeTab !== "scope") return { kind: "project" }; const custom = customScopeName(o.namedScope); if (custom !== null) { diff --git a/src/features/viewers/markdown/render.test.ts b/src/features/viewers/markdown/render.test.ts index 0a5e4b0fb4..a062b6993e 100644 --- a/src/features/viewers/markdown/render.test.ts +++ b/src/features/viewers/markdown/render.test.ts @@ -231,6 +231,7 @@ describe("markdown preview rendering", () => { }); expect(resolveLink(file, "javascript:alert(1)")).toBeNull(); expect(joinPath("C:/repo/docs", "../a.md")).toBe("C:/repo/a.md"); + expect(joinPath("C:/repo/docs", "D:/shared/a.md")).toBe("D:/shared/a.md"); expect(joinPath("/repo", "../../a.md")).toBe("/a.md"); }); diff --git a/src/features/viewers/markdown/render.ts b/src/features/viewers/markdown/render.ts index f670d08ea9..0e561759b2 100644 --- a/src/features/viewers/markdown/render.ts +++ b/src/features/viewers/markdown/render.ts @@ -192,9 +192,9 @@ export type LinkTarget = /** Directory of `file` (forward slashes). */ const dirOf = (file: string) => file.slice(0, Math.max(0, file.lastIndexOf("/"))); -/** Joins `rel` onto `dir`, resolving `.` / `..`. Absolute `rel` (leading `/`) is kept. */ +/** Joins `rel` onto `dir`, resolving `.` / `..`. Absolute `rel` (`/…` or `C:/…`) is kept. */ export function joinPath(dir: string, rel: string): string { - const parts = (rel.startsWith("/") ? rel : `${dir}/${rel}`).split("/"); + const parts = (rel.startsWith("/") || /^[A-Za-z]:\//.test(rel) ? rel : `${dir}/${rel}`).split("/"); const out: string[] = []; for (const p of parts) { if (p === "..") {