MCPcopy Create free account
hub / github.com/continuedev/continue / getSearchResults

Method getSearchResults

extensions/vscode/src/VsCodeIde.ts:587–629  ·  view source on GitHub ↗
(query: string, maxResults?: number)

Source from the content-addressed store, hash-verified

585 }
586
587 async getSearchResults(query: string, maxResults?: number): Promise<string> {
588 if (vscode.env.remoteName) {
589 throw new Error("Ripgrep not supported, this workspace is remote");
590 }
591 const results: string[] = [];
592
593 for (const dir of await this.getWorkspaceDirs()) {
594 const dirResults = await this.runRipgrepQuery(dir, [
595 "-i", // Case-insensitive search
596 "--ignore-file",
597 ".continueignore",
598 "--ignore-file",
599 ".gitignore",
600 "-C",
601 "2", // Show 2 lines of context
602 "--heading", // Only show filepath once per result
603 // Use a single glob with all default ignores
604 "--glob",
605 defaultIgnoresGlob,
606 ...(maxResults ? ["-m", maxResults.toString()] : []),
607 "-e",
608 query, // Pattern to search for
609 ".", // Directory to search in
610 ]);
611
612 results.push(dirResults);
613 }
614
615 const allResults = results.join("\n");
616 if (maxResults) {
617 // In case of multiple workspaces, do max results per workspace and then truncate to maxResults
618 // Will prioritize first workspace results, fine for now
619 // Results are separated by either ./ or --
620 const matches = Array.from(allResults.matchAll(/(\n--|\n\.\/)/g));
621 if (matches.length > maxResults) {
622 return allResults.substring(0, matches[maxResults].index);
623 } else {
624 return allResults;
625 }
626 } else {
627 return allResults;
628 }
629 }
630
631 async getProblems(fileUri?: string | undefined): Promise<Problem[]> {
632 const uri = fileUri

Callers

nothing calls this directly

Calls 4

getWorkspaceDirsMethod · 0.95
runRipgrepQueryMethod · 0.95
fromMethod · 0.80
pushMethod · 0.65

Tested by

no test coverage detected