diff options
| author | Scott Densmore <[email protected]> | 2025-05-31 16:19:14 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-05-31 16:19:14 -0700 |
| commit | c414512f1999b48a0dc02fed14e793b650907ba8 (patch) | |
| tree | bb9b1e37dd474118fb9a97fe57494d725d7b901f /packages/cli/src/ui/hooks/useCompletion.ts | |
| parent | b1d693786c2beaa8ba14af292894aa3e3a66ac4b (diff) | |
Fix: Make file path case-insensitive in @-command (#659)
Diffstat (limited to 'packages/cli/src/ui/hooks/useCompletion.ts')
| -rw-r--r-- | packages/cli/src/ui/hooks/useCompletion.ts | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/packages/cli/src/ui/hooks/useCompletion.ts b/packages/cli/src/ui/hooks/useCompletion.ts index f2c85458..f3ad7847 100644 --- a/packages/cli/src/ui/hooks/useCompletion.ts +++ b/packages/cli/src/ui/hooks/useCompletion.ts @@ -193,6 +193,7 @@ export function useCompletion( return []; } + const lowerSearchPrefix = searchPrefix.toLowerCase(); let foundSuggestions: Suggestion[] = []; try { const entries = await fs.readdir(startDir, { withFileTypes: true }); @@ -200,7 +201,7 @@ export function useCompletion( if (foundSuggestions.length >= maxResults) break; const entryPathRelative = path.join(currentRelativePath, entry.name); - if (entry.name.startsWith(searchPrefix)) { + if (entry.name.toLowerCase().startsWith(lowerSearchPrefix)) { foundSuggestions.push({ label: entryPathRelative + (entry.isDirectory() ? '/' : ''), value: escapePath( @@ -217,7 +218,7 @@ export function useCompletion( foundSuggestions = foundSuggestions.concat( await findFilesRecursively( path.join(startDir, entry.name), - searchPrefix, + searchPrefix, // Pass original searchPrefix for recursive calls entryPathRelative, depth + 1, maxDepth, @@ -242,11 +243,12 @@ export function useCompletion( fetchedSuggestions = await findFilesRecursively(cwd, prefix); } else { // Original behavior: list files in the specific directory + const lowerPrefix = prefix.toLowerCase(); const entries = await fs.readdir(baseDirAbsolute, { withFileTypes: true, }); fetchedSuggestions = entries - .filter((entry) => entry.name.startsWith(prefix)) + .filter((entry) => entry.name.toLowerCase().startsWith(lowerPrefix)) .map((entry) => { const label = entry.isDirectory() ? entry.name + '/' : entry.name; return { |
