Bug/1369 at command recursive search (#1370)
This commit is contained in:
parent
a2ed4266aa
commit
b47a4240ff
|
@ -21,6 +21,7 @@ const mockConfig = {
|
||||||
isSandboxed: vi.fn(() => false),
|
isSandboxed: vi.fn(() => false),
|
||||||
getFileService: vi.fn(),
|
getFileService: vi.fn(),
|
||||||
getFileFilteringRespectGitIgnore: vi.fn(() => true),
|
getFileFilteringRespectGitIgnore: vi.fn(() => true),
|
||||||
|
getEnableRecursiveFileSearch: vi.fn(() => true),
|
||||||
} as unknown as Config;
|
} as unknown as Config;
|
||||||
|
|
||||||
const mockReadManyFilesExecute = vi.fn();
|
const mockReadManyFilesExecute = vi.fn();
|
||||||
|
@ -720,4 +721,35 @@ describe('handleAtCommand', () => {
|
||||||
expect(result.shouldProceed).toBe(true);
|
expect(result.shouldProceed).toBe(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('when recursive file search is disabled', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
vi.mocked(mockConfig.getEnableRecursiveFileSearch).mockReturnValue(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not use glob search for a nonexistent file', async () => {
|
||||||
|
const invalidFile = 'nonexistent.txt';
|
||||||
|
const query = `@${invalidFile}`;
|
||||||
|
|
||||||
|
vi.mocked(fsPromises.stat).mockRejectedValue(
|
||||||
|
Object.assign(new Error('ENOENT'), { code: 'ENOENT' }),
|
||||||
|
);
|
||||||
|
|
||||||
|
const result = await handleAtCommand({
|
||||||
|
query,
|
||||||
|
config: mockConfig,
|
||||||
|
addItem: mockAddItem,
|
||||||
|
onDebugMessage: mockOnDebugMessage,
|
||||||
|
messageId: 300,
|
||||||
|
signal: abortController.signal,
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(mockGlobExecute).not.toHaveBeenCalled();
|
||||||
|
expect(mockOnDebugMessage).toHaveBeenCalledWith(
|
||||||
|
`Glob tool not found. Path ${invalidFile} will be skipped.`,
|
||||||
|
);
|
||||||
|
expect(result.processedQuery).toEqual([{ text: query }]);
|
||||||
|
expect(result.shouldProceed).toBe(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -210,10 +210,10 @@ export async function handleAtCommand({
|
||||||
resolvedSuccessfully = true;
|
resolvedSuccessfully = true;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (isNodeError(error) && error.code === 'ENOENT') {
|
if (isNodeError(error) && error.code === 'ENOENT') {
|
||||||
|
if (config.getEnableRecursiveFileSearch() && globTool) {
|
||||||
onDebugMessage(
|
onDebugMessage(
|
||||||
`Path ${pathName} not found directly, attempting glob search.`,
|
`Path ${pathName} not found directly, attempting glob search.`,
|
||||||
);
|
);
|
||||||
if (globTool) {
|
|
||||||
try {
|
try {
|
||||||
const globResult = await globTool.execute(
|
const globResult = await globTool.execute(
|
||||||
{ pattern: `**/*${pathName}*`, path: config.getTargetDir() },
|
{ pattern: `**/*${pathName}*`, path: config.getTargetDir() },
|
||||||
|
|
Loading…
Reference in New Issue