Skip to content

Commit 6859934

Browse files
committed
fix multiple workspaces grep logic
1 parent 75db17f commit 6859934

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

extensions/vscode/src/VsCodeIde.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -548,11 +548,19 @@ class VsCodeIde implements IDE {
548548
results.push(dirResults);
549549
}
550550

551+
const allResults = results.join("\n");
551552
if (maxResults) {
552-
// With multiple workspaces, we will pull max results from EACH workspace and then truncate to max results just in case
553-
return results.join("\n").split("\n./").slice(0, maxResults).join("\n./");
553+
// In case of multiple workspaces, do max results per workspace and then truncate to maxResults
554+
// Will prioritize first workspace results, fine for now
555+
// Results are separated by either ./ or --
556+
const matches = Array.from(allResults.matchAll(/(\n--|\n\.\/)/g));
557+
if (matches.length > maxResults) {
558+
return allResults.substring(0, matches[maxResults].index);
559+
} else {
560+
return allResults;
561+
}
554562
} else {
555-
return results.join("\n");
563+
return allResults;
556564
}
557565
}
558566

0 commit comments

Comments
 (0)