From 5d9ff1985cfbef2c66847e56a36f688afb3777d8 Mon Sep 17 00:00:00 2001 From: daniel-lxs Date: Fri, 24 Oct 2025 14:01:46 -0500 Subject: [PATCH] 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 --- src/services/ripgrep/index.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/services/ripgrep/index.ts b/src/services/ripgrep/index.ts index d384b27c91c..5dd800ac6f7 100644 --- a/src/services/ripgrep/index.ts +++ b/src/services/ripgrep/index.ts @@ -150,7 +150,15 @@ export async function regexSearchFiles( throw new Error("Could not find ripgrep binary") } - const args = ["--json", "-e", regex, "--glob", filePattern || "*", "--context", "1", "--no-messages", directoryPath] + const args = ["--json", "-e", regex] + + // Only add --glob if a specific file pattern is provided + // Using --glob "*" overrides .gitignore behavior, so we omit it when no pattern is specified + if (filePattern) { + args.push("--glob", filePattern) + } + + args.push("--context", "1", "--no-messages", directoryPath) let output: string try {