diff --git a/apps/web/src/terminal-links.test.ts b/apps/web/src/terminal-links.test.ts index 0d081ca4af6fa..54b44d42c369a 100644 --- a/apps/web/src/terminal-links.test.ts +++ b/apps/web/src/terminal-links.test.ts @@ -207,6 +207,11 @@ describe("extractTerminalLinks", () => { "/app/src/Program.cs(12,5)", "/app/src/Program.cs:12:5", ], + [ + "src/Program.cs(12,5): error CS1002: ; expected", + "src/Program.cs(12,5)", + "src/Program.cs:12:5", + ], [ String.raw`C:\app\UnitTest1.cs(12): error VSTEST1: Assert.True() Failure`, String.raw`C:\app\UnitTest1.cs(12)`, @@ -448,7 +453,7 @@ describe("resolvePathLinkTarget", () => { ["/tmp/report:[42,7]", "/tmp/report:[42,7]"], ["/tmp/notes:line 29", "/tmp/notes:line"], ["/tmp/ok.py(3)f()", "/tmp/ok.py(3)f()"], - ["src/Program.cs(3,10): error CS1002: x", "/repo/src/Program.cs"], + ["src/Program.cs(3,10): error CS1002: x", "/repo/src/Program.cs(3,10)"], ])("preserves existing path targets in %s", (line, target) => { const [link] = extractTerminalLinks(line); expect(resolveTerminalLinkTarget(link?.text ?? "", "/repo")).toBe(target); diff --git a/apps/web/src/terminal-links.ts b/apps/web/src/terminal-links.ts index f64fd48bc71ff..74c5e38272abb 100644 --- a/apps/web/src/terminal-links.ts +++ b/apps/web/src/terminal-links.ts @@ -42,7 +42,7 @@ const POWERSHELL_PROMPT_PATH_PATTERN = /^PS ((?:[A-Za-z]:[\\/]|\\\\|\/)[^>\r\n]* // Parenthesized path segments need a following slash to distinguish compiler locations. // A bare `name.ext` needs `:line:col` or a TS location after it, so prose and `host:port` stay text. const FILE_PATH_PATTERN = - /(?:~[\\/]|\.{1,2}[\\/]|\/|[A-Za-z]:[\\/]|\\\\)[^\s"'`<>]+|(?]+|(?(?:~[\\/]|\.{1,2}[\\/]|\/|[A-Za-z]:[\\/]|\\\\|[\p{L}\p{M}\p{N}._ -]+[\\/])[^\r\n]*?|[\p{L}\p{M}\p{N}._ -]+\.[\p{L}\p{M}\p{N}_-]+(?::\d+){0,2})\1(?(?::\d+){0,2})/gu; // The `:line` or `:line:col` that grep, ripgrep and Ruby backtraces follow with a colon and text.