mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-20 08:47:44 +00:00
Improve the performance of filename completion over large repositories. (#938)
This commit is contained in:
@@ -42,6 +42,7 @@ describe('useCompletion git-aware filtering integration', () => {
|
||||
shouldIgnoreFile: vi.fn(),
|
||||
filterFiles: vi.fn(),
|
||||
getIgnoreInfo: vi.fn(() => ({ gitIgnored: [], customIgnored: [] })),
|
||||
glob: vi.fn().mockResolvedValue([]),
|
||||
};
|
||||
|
||||
mockConfig = {
|
||||
@@ -225,4 +226,27 @@ describe('useCompletion git-aware filtering integration', () => {
|
||||
{ label: 'component.tsx', value: 'component.tsx' },
|
||||
]);
|
||||
});
|
||||
|
||||
it('should use glob for top-level @ completions when available', async () => {
|
||||
const globResults = [`${testCwd}/src/index.ts`, `${testCwd}/README.md`];
|
||||
mockFileDiscoveryService.glob.mockResolvedValue(globResults);
|
||||
|
||||
const { result } = renderHook(() =>
|
||||
useCompletion('@s', testCwd, true, slashCommands, mockConfig),
|
||||
);
|
||||
|
||||
await act(async () => {
|
||||
await new Promise((resolve) => setTimeout(resolve, 150));
|
||||
});
|
||||
|
||||
expect(mockFileDiscoveryService.glob).toHaveBeenCalledWith('**/s*', {
|
||||
cwd: testCwd,
|
||||
dot: true,
|
||||
});
|
||||
expect(fs.readdir).not.toHaveBeenCalled(); // Ensure glob is used instead of readdir
|
||||
expect(result.current.suggestions).toEqual([
|
||||
{ label: 'README.md', value: 'README.md' },
|
||||
{ label: 'src/index.ts', value: 'src/index.ts' },
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user