mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-09-05 08:10:14 +00:00
fix: list_files recursive mode now works correctly for hidden directories
- Fixed ripgrep exclusion pattern from `!**/.*//**` to `!**/.*/**` - Hidden directories (like .git/) now appear in recursive listings but their contents are excluded - Contents of hidden directories are only shown when explicitly targeting that directory - Prevents context window overflow from massive hidden directories like .git/ - Maintains consistent behavior: show directory exists, avoid flooding with contents Fixes #2992
This commit is contained in:
parent
649a69e90d
commit
f71bbf0d34
1 changed files with 16 additions and 6 deletions
|
|
@ -192,7 +192,7 @@ function buildRipgrepArgs(dirPath: string, recursive: boolean): string[] {
|
|||
const args = ["--files", "--hidden", "--follow"]
|
||||
|
||||
if (recursive) {
|
||||
return [...args, ...buildRecursiveArgs(), dirPath]
|
||||
return [...args, ...buildRecursiveArgs(dirPath), dirPath]
|
||||
} else {
|
||||
return [...args, ...buildNonRecursiveArgs(), dirPath]
|
||||
}
|
||||
|
|
@ -201,25 +201,31 @@ function buildRipgrepArgs(dirPath: string, recursive: boolean): string[] {
|
|||
/**
|
||||
* Build ripgrep arguments for recursive directory traversal
|
||||
*/
|
||||
function buildRecursiveArgs(): string[] {
|
||||
function buildRecursiveArgs(dirPath: string): string[] {
|
||||
const args: string[] = []
|
||||
|
||||
// In recursive mode, respect .gitignore by default
|
||||
// (ripgrep does this automatically)
|
||||
|
||||
// Check if we're explicitly targeting a hidden directory
|
||||
const targetDirName = path.basename(dirPath)
|
||||
const isTargetingHiddenDir = targetDirName.startsWith(".")
|
||||
|
||||
// Apply directory exclusions for recursive searches
|
||||
for (const dir of DIRS_TO_IGNORE) {
|
||||
// Special handling for hidden directories pattern
|
||||
if (dir === ".*") {
|
||||
// Don't exclude hidden directories at the ripgrep level for recursive mode
|
||||
// Only exclude hidden directories if we're not explicitly targeting one
|
||||
// This allows explicitly targeted hidden directories to be processed
|
||||
// Hidden subdirectories will be filtered during directory traversal instead
|
||||
// while excluding them from general recursive searches
|
||||
if (!isTargetingHiddenDir) {
|
||||
args.push("-g", `!**/.*/**`)
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
args.push("-g", `!**/${dir}/**`)
|
||||
}
|
||||
|
||||
return args
|
||||
}
|
||||
|
||||
|
|
@ -338,7 +344,11 @@ async function listFilteredDirectories(
|
|||
directories.push(formattedPath)
|
||||
|
||||
// If recursive mode and not a ignored directory, scan subdirectories
|
||||
if (recursive && !isDirectoryExplicitlyIgnored(dirName)) {
|
||||
// Don't recurse into hidden directories unless they are the explicit target
|
||||
const isHiddenDir = dirName.startsWith(".")
|
||||
const shouldRecurse =
|
||||
recursive && !isDirectoryExplicitlyIgnored(dirName) && !(isHiddenDir && !isTargetDir)
|
||||
if (shouldRecurse) {
|
||||
await scanDirectory(fullDirPath, false) // Subdirectories are not target dirs
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue