diff options
| author | Sandy Tao <[email protected]> | 2025-07-14 14:10:26 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-07-14 21:10:26 +0000 |
| commit | 7ffe8038efaa5bf263a2a933819bcd4badd37dc2 (patch) | |
| tree | a8f0b54a990850c98a96f48165351fa735bc9b02 /packages/cli/src/ui/hooks/useCompletion.ts | |
| parent | ff3722a3a74b09cd25b03de41933944a55db6351 (diff) | |
Make @ command sort file without extension name (#4158)
Diffstat (limited to 'packages/cli/src/ui/hooks/useCompletion.ts')
| -rw-r--r-- | packages/cli/src/ui/hooks/useCompletion.ts | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/packages/cli/src/ui/hooks/useCompletion.ts b/packages/cli/src/ui/hooks/useCompletion.ts index 1f6e570d..8b3f6991 100644 --- a/packages/cli/src/ui/hooks/useCompletion.ts +++ b/packages/cli/src/ui/hooks/useCompletion.ts @@ -471,7 +471,19 @@ export function useCompletion( if (aIsDir && !bIsDir) return -1; if (!aIsDir && bIsDir) return 1; - return a.label.localeCompare(b.label); + // exclude extension when comparing + const filenameA = a.label.substring( + 0, + a.label.length - path.extname(a.label).length, + ); + const filenameB = b.label.substring( + 0, + b.label.length - path.extname(b.label).length, + ); + + return ( + filenameA.localeCompare(filenameB) || a.label.localeCompare(b.label) + ); }); if (isMounted) { |
