Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion core/util/grepSearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
Expand Down
18 changes: 18 additions & 0 deletions core/util/grepSearch.vitest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
});
Loading