diff --git a/src/services/code-index/processors/file-watcher.ts b/src/services/code-index/processors/file-watcher.ts index 1e5ebcbcebc..a6a3122c36c 100644 --- a/src/services/code-index/processors/file-watcher.ts +++ b/src/services/code-index/processors/file-watcher.ts @@ -508,8 +508,12 @@ export class FileWatcher implements IFileWatcher { */ async processFile(filePath: string): Promise { try { + // Get relative path for ignore checks + const relativeFilePath = generateRelativeFilePath(filePath, this.workspacePath) + // Check if file is in an ignored directory - if (isPathInIgnoredDirectory(filePath)) { + // Use relative path to avoid matching parent directories outside the workspace + if (isPathInIgnoredDirectory(relativeFilePath)) { return { path: filePath, status: "skipped" as const, @@ -518,7 +522,6 @@ export class FileWatcher implements IFileWatcher { } // Check if file should be ignored - const relativeFilePath = generateRelativeFilePath(filePath, this.workspacePath) if ( !this.ignoreController.validateAccess(filePath) || (this.ignoreInstance && this.ignoreInstance.ignores(relativeFilePath)) diff --git a/src/services/code-index/processors/scanner.ts b/src/services/code-index/processors/scanner.ts index 92a7d77c272..91689a56d7c 100644 --- a/src/services/code-index/processors/scanner.ts +++ b/src/services/code-index/processors/scanner.ts @@ -96,7 +96,8 @@ export class DirectoryScanner implements IDirectoryScanner { const relativeFilePath = generateRelativeFilePath(filePath, scanWorkspace) // Check if file is in an ignored directory using the shared helper - if (isPathInIgnoredDirectory(filePath)) { + // Use relative path to avoid matching parent directories outside the workspace + if (isPathInIgnoredDirectory(relativeFilePath)) { return false }