Skip to content

Commit b025102

Browse files
committed
fix(web): keep Windows paths outside workspace
1 parent 8b74a69 commit b025102

2 files changed

Lines changed: 30 additions & 1 deletion

File tree

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { describe, expect, it } from "vite-plus/test";
2+
3+
import { formatWorkspaceRelativePath } from "./filePathDisplay";
4+
5+
describe("formatWorkspaceRelativePath", () => {
6+
it("leaves Windows absolute paths outside the workspace alone", () => {
7+
expect(
8+
formatWorkspaceRelativePath(
9+
"C:\\Users\\mike\\.claude\\settings.json:3",
10+
"C:\\Users\\mike\\dev-stuff\\t3code",
11+
),
12+
).toBe("C:/Users/mike/.claude/settings.json:3");
13+
expect(
14+
formatWorkspaceRelativePath("D:/data/report.csv", "C:/Users/mike/dev-stuff/t3code"),
15+
).toBe("D:/data/report.csv");
16+
});
17+
18+
it("still labels relative and in-workspace paths with the workspace name", () => {
19+
expect(formatWorkspaceRelativePath("src/app.ts", "C:/Users/mike/dev-stuff/t3code")).toBe(
20+
"t3code/src/app.ts",
21+
);
22+
expect(
23+
formatWorkspaceRelativePath(
24+
"c:\\users\\mike\\dev-stuff\\t3code\\src\\app.ts:7",
25+
"C:\\Users\\mike\\dev-stuff\\t3code",
26+
),
27+
).toBe("t3code/src/app.ts:7");
28+
});
29+
});

‎apps/web/src/filePathDisplay.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export function formatWorkspaceRelativePath(
4646
} else if (pathForCompare.startsWith(workspaceWithSeparator)) {
4747
const relativeSuffix = normalizedPath.slice(normalizedWorkspaceRoot.length + 1);
4848
displayPath = `${workspaceLabel}/${relativeSuffix}`;
49-
} else if (!normalizedPath.startsWith("/")) {
49+
} else if (!normalizedPath.startsWith("/") && !isWindowsAbsolutePath(normalizedPath)) {
5050
const relativePath = stripRelativePrefixes(normalizedPath);
5151
displayPath = pathForCompare.startsWith(workspaceLabelWithSeparator)
5252
? normalizedPath

0 commit comments

Comments
 (0)