(
pattern: string,
maxResults?: number,
)
| 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}`; |
nothing calls this directly
no test coverage detected