Skip to content

Commit 5d9ff19

Browse files
committed
fix: respect nested .gitignore files in search_files
The issue was caused by unconditionally adding --glob '*' to ripgrep args, which overrides ripgrep's native .gitignore handling. Now only adds --glob when a specific file pattern is provided by the user. Fixes #7921
1 parent 19e0690 commit 5d9ff19

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/services/ripgrep/index.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,15 @@ export async function regexSearchFiles(
150150
throw new Error("Could not find ripgrep binary")
151151
}
152152

153-
const args = ["--json", "-e", regex, "--glob", filePattern || "*", "--context", "1", "--no-messages", directoryPath]
153+
const args = ["--json", "-e", regex]
154+
155+
// Only add --glob if a specific file pattern is provided
156+
// Using --glob "*" overrides .gitignore behavior, so we omit it when no pattern is specified
157+
if (filePattern) {
158+
args.push("--glob", filePattern)
159+
}
160+
161+
args.push("--context", "1", "--no-messages", directoryPath)
154162

155163
let output: string
156164
try {

0 commit comments

Comments
 (0)