diff --git a/core/util/grepSearch.ts b/core/util/grepSearch.ts index be5b7ee082f..09051dc13bd 100644 --- a/core/util/grepSearch.ts +++ b/core/util/grepSearch.ts @@ -57,7 +57,9 @@ export function formatGrepSearchResults( let resultLines: string[] = []; for (const line of results.split("\n").filter((l) => !!l)) { - if (line.startsWith("./") || line === "--") { + // ripgrep headings start with the relative path: "./" on POSIX, ".\" on Windows. + // Only checking "./" silently discarded every match on Windows (#13027). + if (line.startsWith("./") || line.startsWith(".\\") || line === "--") { processResult(resultLines); // process previous result resultLines = [line]; numResults++; diff --git a/core/util/grepSearch.vitest.ts b/core/util/grepSearch.vitest.ts index df1a71efd82..aae7270caea 100644 --- a/core/util/grepSearch.vitest.ts +++ b/core/util/grepSearch.vitest.ts @@ -215,3 +215,21 @@ test("decreases indentation when original is more than 2 spaces", () => { expect(result.formatted).toContain(" tooMuchIndent();"); expect(result.formatted).toContain(" }"); }); + +test("parses Windows ripgrep output with backslash path separators", () => { + // On Windows, ripgrep emits headings like `.\dir\file.ext` instead of `./dir/file.ext`. + // The parser must recognise those as file headers, otherwise every match is discarded (#13027). + const windowsOutput = [ + ".\\src\\program.cs", + ' Console.WriteLine("Hello World!");', + "--", + ".\\test\\calc.kt", + " fun subtract(number: Double): Test {", + ].join("\n"); + + const result = formatGrepSearchResults(windowsOutput); + + expect(result.numResults).toBeGreaterThan(0); + expect(result.formatted).toContain("program.cs"); + expect(result.formatted).toContain("calc.kt"); +});