mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-20 16:57:46 +00:00
feat(file-search): Add support for non-recursive file search (#5648)
Co-authored-by: Jacob Richman <jacob314@gmail.com>
This commit is contained in:
@@ -50,6 +50,7 @@ describe('useAtCompletion', () => {
|
||||
respectGitIgnore: true,
|
||||
respectGeminiIgnore: true,
|
||||
})),
|
||||
getEnableRecursiveFileSearch: () => true,
|
||||
} as unknown as Config;
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
@@ -431,5 +432,42 @@ describe('useAtCompletion', () => {
|
||||
await cleanupTmpDir(rootDir1);
|
||||
await cleanupTmpDir(rootDir2);
|
||||
});
|
||||
|
||||
it('should perform a non-recursive search when enableRecursiveFileSearch is false', async () => {
|
||||
const structure: FileSystemStructure = {
|
||||
'file.txt': '',
|
||||
src: {
|
||||
'index.js': '',
|
||||
},
|
||||
};
|
||||
testRootDir = await createTmpDir(structure);
|
||||
|
||||
const nonRecursiveConfig = {
|
||||
getEnableRecursiveFileSearch: () => false,
|
||||
getFileFilteringOptions: vi.fn(() => ({
|
||||
respectGitIgnore: true,
|
||||
respectGeminiIgnore: true,
|
||||
})),
|
||||
} as unknown as Config;
|
||||
|
||||
const { result } = renderHook(() =>
|
||||
useTestHarnessForAtCompletion(
|
||||
true,
|
||||
'',
|
||||
nonRecursiveConfig,
|
||||
testRootDir,
|
||||
),
|
||||
);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(result.current.suggestions.length).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
// Should only contain top-level items
|
||||
expect(result.current.suggestions.map((s) => s.value)).toEqual([
|
||||
'src/',
|
||||
'file.txt',
|
||||
]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -165,6 +165,9 @@ export function useAtCompletion(props: UseAtCompletionProps): void {
|
||||
config?.getFileFilteringOptions()?.respectGeminiIgnore ?? true,
|
||||
cache: true,
|
||||
cacheTtl: 30, // 30 seconds
|
||||
maxDepth: !(config?.getEnableRecursiveFileSearch() ?? true)
|
||||
? 0
|
||||
: undefined,
|
||||
});
|
||||
await searcher.initialize();
|
||||
fileSearch.current = searcher;
|
||||
|
||||
Reference in New Issue
Block a user