Skip to content
Closed
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ bin/
# Local prompts and rules
/local-prompts

# Roo temp files
.roo/temp/

# Test environment
.test_env
.vscode-test/
Expand Down
24 changes: 22 additions & 2 deletions src/services/code-index/processors/file-watcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ import {
import { codeParser } from "./parser"
import { CacheManager } from "../cache-manager"
import { generateNormalizedAbsolutePath, generateRelativeFilePath } from "../shared/get-relative-path"
import { isPathInIgnoredDirectory } from "../../glob/ignore-utils"
import { DIRS_TO_IGNORE } from "../../glob/constants"
import * as path from "path"

/**
* Implementation of the file watcher interface
Expand Down Expand Up @@ -455,7 +456,7 @@ export class FileWatcher implements IFileWatcher {
async processFile(filePath: string): Promise<FileProcessingResult> {
try {
// Check if file is in an ignored directory
if (isPathInIgnoredDirectory(filePath)) {
if (this.isPathInIgnoredDirectory(filePath)) {
return {
path: filePath,
status: "skipped" as const,
Expand Down Expand Up @@ -543,4 +544,23 @@ export class FileWatcher implements IFileWatcher {
}
}
}

/**
* Check if a path is within an ignored directory
*/
private isPathInIgnoredDirectory(filePath: string): boolean {
const normalizedPath = path.normalize(filePath)
const pathParts = normalizedPath.split(path.sep)

return pathParts.some((part) => {
// Check if any part of the path matches an ignored directory
return DIRS_TO_IGNORE.some((dir) => {
if (dir === ".*") {
// Special case for hidden directories (starting with .)
return part.startsWith(".") && part !== "."
}
return part === dir
})
})
}
}
25 changes: 22 additions & 3 deletions src/services/code-index/processors/scanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
PARSING_CONCURRENCY,
BATCH_PROCESSING_CONCURRENCY,
} from "../constants"
import { isPathInIgnoredDirectory } from "../../glob/ignore-utils"
import { DIRS_TO_IGNORE } from "../../glob/constants"

export class DirectoryScanner implements IDirectoryScanner {
constructor(
Expand Down Expand Up @@ -68,8 +68,8 @@ export class DirectoryScanner implements IDirectoryScanner {
const ext = path.extname(filePath).toLowerCase()
const relativeFilePath = generateRelativeFilePath(filePath)

// Check if file is in an ignored directory using the shared helper
if (isPathInIgnoredDirectory(filePath)) {
// Check if file is in an ignored directory
if (this.isPathInIgnoredDirectory(filePath)) {
return false
}

Expand Down Expand Up @@ -362,4 +362,23 @@ export class DirectoryScanner implements IDirectoryScanner {
}
}
}

/**
* Check if a path is within an ignored directory
*/
private isPathInIgnoredDirectory(filePath: string): boolean {
const normalizedPath = path.normalize(filePath)
const pathParts = normalizedPath.split(path.sep)

return pathParts.some((part) => {
// Check if any part of the path matches an ignored directory
return DIRS_TO_IGNORE.some((dir) => {
if (dir === ".*") {
// Special case for hidden directories (starting with .)
return part.startsWith(".") && part !== "."
}
return part === dir
})
})
}
}
Loading