From 68599341c580a843f96752e37ec3e77bcb770127 Mon Sep 17 00:00:00 2001 From: Dallin Romney Date: Thu, 19 Jun 2025 18:52:39 -0700 Subject: [PATCH] fix multiple workspaces grep logic --- extensions/vscode/src/VsCodeIde.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/extensions/vscode/src/VsCodeIde.ts b/extensions/vscode/src/VsCodeIde.ts index 04f39f1db..bb701db6a 100644 --- a/extensions/vscode/src/VsCodeIde.ts +++ b/extensions/vscode/src/VsCodeIde.ts @@ -548,11 +548,19 @@ class VsCodeIde implements IDE { results.push(dirResults); } + const allResults = results.join("\n"); if (maxResults) { - // With multiple workspaces, we will pull max results from EACH workspace and then truncate to max results just in case - return results.join("\n").split("\n./").slice(0, maxResults).join("\n./"); + // In case of multiple workspaces, do max results per workspace and then truncate to maxResults + // Will prioritize first workspace results, fine for now + // Results are separated by either ./ or -- + const matches = Array.from(allResults.matchAll(/(\n--|\n\.\/)/g)); + if (matches.length > maxResults) { + return allResults.substring(0, matches[maxResults].index); + } else { + return allResults; + } } else { - return results.join("\n"); + return allResults; } }