Ignore dot files on @-completion. (#978)

This commit is contained in:
DeWitt Clinton
2025-06-12 10:04:15 -07:00
committed by GitHub
parent af247a6cbd
commit a9e56ee460
2 changed files with 39 additions and 2 deletions

View File

@@ -241,7 +241,7 @@ describe('useCompletion git-aware filtering integration', () => {
expect(mockFileDiscoveryService.glob).toHaveBeenCalledWith('**/s*', {
cwd: testCwd,
dot: true,
dot: false,
});
expect(fs.readdir).not.toHaveBeenCalled(); // Ensure glob is used instead of readdir
expect(result.current.suggestions).toEqual([
@@ -249,4 +249,32 @@ describe('useCompletion git-aware filtering integration', () => {
{ label: 'src/index.ts', value: 'src/index.ts' },
]);
});
it('should include dotfiles in glob search when input starts with a dot', async () => {
const globResults = [
`${testCwd}/.env`,
`${testCwd}/.gitignore`,
`${testCwd}/src/index.ts`,
];
mockFileDiscoveryService.glob.mockResolvedValue(globResults);
const { result } = renderHook(() =>
useCompletion('@.', testCwd, true, slashCommands, mockConfig),
);
await act(async () => {
await new Promise((resolve) => setTimeout(resolve, 150));
});
expect(mockFileDiscoveryService.glob).toHaveBeenCalledWith('**/.*', {
cwd: testCwd,
dot: true,
});
expect(fs.readdir).not.toHaveBeenCalled();
expect(result.current.suggestions).toEqual([
{ label: '.env', value: '.env' },
{ label: '.gitignore', value: '.gitignore' },
{ label: 'src/index.ts', value: 'src/index.ts' },
]);
});
});