fix(core): ripgrep fails when pattern looks like ripgrep flag (#18858)

Co-authored-by: Tommaso Sciortino <sciortino@gmail.com>
This commit is contained in:
Smitty
2026-02-18 17:11:24 -05:00
committed by GitHub
parent 8910b2720f
commit 221ea360b9
2 changed files with 11 additions and 8 deletions
+9 -5
View File
@@ -1430,11 +1430,15 @@ describe('RipGrepTool', () => {
}); });
const result = await invocation.execute(abortSignal); const result = await invocation.execute(abortSignal);
expect(mockSpawn).toHaveBeenLastCalledWith( const spawnArgs = mockSpawn.mock.calls[0][1];
expect.anything(), expect(spawnArgs).toContain('--fixed-strings');
expect.arrayContaining(['--fixed-strings']), expect(spawnArgs).toContain('--regexp');
expect.anything(), expect(spawnArgs).toContain('hello.world');
);
// Verify --fixed-strings doesn't have the pattern as its next argument
const fixedStringsIdx = spawnArgs.indexOf('--fixed-strings');
expect(spawnArgs[fixedStringsIdx + 1]).not.toBe('hello.world');
expect(result.llmContent).toContain( expect(result.llmContent).toContain(
'Found 1 match for pattern "hello.world"', 'Found 1 match for pattern "hello.world"',
); );
+2 -3
View File
@@ -387,11 +387,10 @@ class GrepToolInvocation extends BaseToolInvocation<
if (fixed_strings) { if (fixed_strings) {
rgArgs.push('--fixed-strings'); rgArgs.push('--fixed-strings');
rgArgs.push(pattern);
} else {
rgArgs.push('--regexp', pattern);
} }
rgArgs.push('--regexp', pattern);
if (context) { if (context) {
rgArgs.push('--context', context.toString()); rgArgs.push('--context', context.toString());
} }