diff options
| author | Anas H. Sulaiman <[email protected]> | 2025-06-14 10:25:34 -0400 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-06-14 14:25:34 +0000 |
| commit | 4873fce7919b4d74cee183a91fa8a3af58aef993 (patch) | |
| tree | c08502c1e4592667160cb006528f868fd6283294 /packages/cli/src/ui/hooks/useCompletion.ts | |
| parent | e6d54771686b3f9537a5a05c9f9101afad3ffdcd (diff) | |
centralize file filtering in `FileDiscoveryService` (#1039)
Diffstat (limited to 'packages/cli/src/ui/hooks/useCompletion.ts')
| -rw-r--r-- | packages/cli/src/ui/hooks/useCompletion.ts | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/packages/cli/src/ui/hooks/useCompletion.ts b/packages/cli/src/ui/hooks/useCompletion.ts index 0aa04263..b7603720 100644 --- a/packages/cli/src/ui/hooks/useCompletion.ts +++ b/packages/cli/src/ui/hooks/useCompletion.ts @@ -7,6 +7,7 @@ import { useState, useEffect, useCallback } from 'react'; import * as fs from 'fs/promises'; import * as path from 'path'; +import { glob } from 'glob'; import { isNodeError, escapePath, @@ -187,7 +188,7 @@ export function useCompletion( const findFilesRecursively = async ( startDir: string, searchPrefix: string, - fileDiscovery: { shouldIgnoreFile: (path: string) => boolean } | null, + fileDiscovery: { shouldGitIgnoreFile: (path: string) => boolean } | null, currentRelativePath = '', depth = 0, maxDepth = 10, // Limit recursion depth @@ -218,7 +219,7 @@ export function useCompletion( // Check if this entry should be ignored by git-aware filtering if ( fileDiscovery && - fileDiscovery.shouldIgnoreFile(entryPathFromRoot) + fileDiscovery.shouldGitIgnoreFile(entryPathFromRoot) ) { continue; } @@ -263,9 +264,10 @@ export function useCompletion( maxResults = 50, ): Promise<Suggestion[]> => { const globPattern = `**/${searchPrefix}*`; - const files = await fileDiscoveryService.glob(globPattern, { + const files = await glob(globPattern, { cwd, dot: searchPrefix.startsWith('.'), + nocase: true, }); const suggestions: Suggestion[] = files @@ -285,9 +287,7 @@ export function useCompletion( setIsLoadingSuggestions(true); let fetchedSuggestions: Suggestion[] = []; - const fileDiscoveryService = config - ? await config.getFileService() - : null; + const fileDiscoveryService = config ? config.getFileService() : null; try { // If there's no slash, or it's the root, do a recursive search from cwd @@ -326,7 +326,7 @@ export function useCompletion( ); if ( fileDiscoveryService && - fileDiscoveryService.shouldIgnoreFile(relativePath) + fileDiscoveryService.shouldGitIgnoreFile(relativePath) ) { continue; } |
