mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-20 16:57:46 +00:00
Fix(grep): memory overflow in grep search and enhance test coverage (#5911)
Co-authored-by: Jacob Richman <jacob314@gmail.com>
This commit is contained in:
@@ -594,4 +594,38 @@ describe('Server Config (config.ts)', () => {
|
||||
expect(config.getTelemetryOtlpProtocol()).toBe('grpc');
|
||||
});
|
||||
});
|
||||
|
||||
describe('UseRipgrep Configuration', () => {
|
||||
it('should default useRipgrep to false when not provided', () => {
|
||||
const config = new Config(baseParams);
|
||||
expect(config.getUseRipgrep()).toBe(false);
|
||||
});
|
||||
|
||||
it('should set useRipgrep to true when provided as true', () => {
|
||||
const paramsWithRipgrep: ConfigParameters = {
|
||||
...baseParams,
|
||||
useRipgrep: true,
|
||||
};
|
||||
const config = new Config(paramsWithRipgrep);
|
||||
expect(config.getUseRipgrep()).toBe(true);
|
||||
});
|
||||
|
||||
it('should set useRipgrep to false when explicitly provided as false', () => {
|
||||
const paramsWithRipgrep: ConfigParameters = {
|
||||
...baseParams,
|
||||
useRipgrep: false,
|
||||
};
|
||||
const config = new Config(paramsWithRipgrep);
|
||||
expect(config.getUseRipgrep()).toBe(false);
|
||||
});
|
||||
|
||||
it('should default useRipgrep to false when undefined', () => {
|
||||
const paramsWithUndefinedRipgrep: ConfigParameters = {
|
||||
...baseParams,
|
||||
useRipgrep: undefined,
|
||||
};
|
||||
const config = new Config(paramsWithUndefinedRipgrep);
|
||||
expect(config.getUseRipgrep()).toBe(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -16,6 +16,7 @@ import { ToolRegistry } from '../tools/tool-registry.js';
|
||||
import { LSTool } from '../tools/ls.js';
|
||||
import { ReadFileTool } from '../tools/read-file.js';
|
||||
import { GrepTool } from '../tools/grep.js';
|
||||
import { RipGrepTool } from '../tools/ripGrep.js';
|
||||
import { GlobTool } from '../tools/glob.js';
|
||||
import { EditTool } from '../tools/edit.js';
|
||||
import { ShellTool } from '../tools/shell.js';
|
||||
@@ -199,6 +200,7 @@ export interface ConfigParameters {
|
||||
chatCompression?: ChatCompressionSettings;
|
||||
interactive?: boolean;
|
||||
trustedFolder?: boolean;
|
||||
useRipgrep?: boolean;
|
||||
shouldUseNodePtyShell?: boolean;
|
||||
skipNextSpeakerCheck?: boolean;
|
||||
enablePromptCompletion?: boolean;
|
||||
@@ -267,6 +269,7 @@ export class Config {
|
||||
private readonly chatCompression: ChatCompressionSettings | undefined;
|
||||
private readonly interactive: boolean;
|
||||
private readonly trustedFolder: boolean | undefined;
|
||||
private readonly useRipgrep: boolean;
|
||||
private readonly shouldUseNodePtyShell: boolean;
|
||||
private readonly skipNextSpeakerCheck: boolean;
|
||||
private readonly enablePromptCompletion: boolean = false;
|
||||
@@ -338,6 +341,7 @@ export class Config {
|
||||
this.chatCompression = params.chatCompression;
|
||||
this.interactive = params.interactive ?? false;
|
||||
this.trustedFolder = params.trustedFolder;
|
||||
this.useRipgrep = params.useRipgrep ?? false;
|
||||
this.shouldUseNodePtyShell = params.shouldUseNodePtyShell ?? false;
|
||||
this.skipNextSpeakerCheck = params.skipNextSpeakerCheck ?? false;
|
||||
this.storage = new Storage(this.targetDir);
|
||||
@@ -727,6 +731,10 @@ export class Config {
|
||||
return this.interactive;
|
||||
}
|
||||
|
||||
getUseRipgrep(): boolean {
|
||||
return this.useRipgrep;
|
||||
}
|
||||
|
||||
getShouldUseNodePtyShell(): boolean {
|
||||
return this.shouldUseNodePtyShell;
|
||||
}
|
||||
@@ -789,7 +797,13 @@ export class Config {
|
||||
|
||||
registerCoreTool(LSTool, this);
|
||||
registerCoreTool(ReadFileTool, this);
|
||||
registerCoreTool(GrepTool, this);
|
||||
|
||||
if (this.getUseRipgrep()) {
|
||||
registerCoreTool(RipGrepTool, this);
|
||||
} else {
|
||||
registerCoreTool(GrepTool, this);
|
||||
}
|
||||
|
||||
registerCoreTool(GlobTool, this);
|
||||
registerCoreTool(EditTool, this);
|
||||
registerCoreTool(WriteFileTool, this);
|
||||
|
||||
Reference in New Issue
Block a user