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

Method getFileResults

extensions/vscode/src/VsCodeIde.ts:476–585  ·  view source on GitHub ↗
(
    pattern: string,
    maxResults?: number,
  )

Source from the content-addressed store, hash-verified

474 }
475
476 async getFileResults(
477 pattern: string,
478 maxResults?: number,
479 ): Promise<string[]> {
480 // Create a single combined ignore pattern for ripgrep (calculated once)
481
482 if (vscode.env.remoteName) {
483 // TODO better tests for this remote search implementation
484 // throw new Error("Ripgrep not supported, this workspace is remote");
485
486 // IMPORTANT: findFiles automatically accounts for .gitignore
487 const ignoreFiles = await vscode.workspace.findFiles(
488 "**/.continueignore",
489 null,
490 );
491
492 const ignoreGlobs: Set<string> = new Set();
493 // Add default ignores from core
494 for (const pattern of DEFAULT_IGNORES) {
495 ignoreGlobs.add(pattern);
496 }
497
498 for (const file of ignoreFiles) {
499 const content = await this.ideUtils.readFile(file);
500 if (content === null) {
501 continue;
502 }
503 const filePath = vscode.workspace.asRelativePath(file);
504 const fileDir = filePath
505 .replace(/\\/g, "/")
506 .replace(/\/$/, "")
507 .split("/")
508 .slice(0, -1)
509 .join("/");
510
511 const patterns = Buffer.from(content)
512 .toString()
513 .split("\n")
514 .map((line) => line.trim())
515 .filter(
516 (line) => line && !line.startsWith("#") && !pattern.startsWith("!"),
517 );
518 // VSCode does not support negations
519
520 patterns
521 // Handle prefix
522 .map((pattern) => {
523 const normalizedPattern = pattern.replace(/\\/g, "/");
524
525 if (normalizedPattern.startsWith("/")) {
526 if (fileDir) {
527 return `{/,}${normalizedPattern}`;
528 } else {
529 return `${fileDir}/${normalizedPattern.substring(1)}`;
530 }
531 } else {
532 if (fileDir) {
533 return `${fileDir}/${normalizedPattern}`;

Callers

nothing calls this directly

Calls 7

getWorkspaceDirsMethod · 0.95
runRipgrepQueryMethod · 0.95
fromMethod · 0.80
addMethod · 0.65
readFileMethod · 0.65
pushMethod · 0.65
replaceMethod · 0.45

Tested by

no test coverage detected