diff options
| author | Tommaso Sciortino <[email protected]> | 2025-07-25 10:32:59 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-07-25 17:32:59 +0000 |
| commit | 3c16429fc4b8102b7ea44c5b2842507e3a99ec72 (patch) | |
| tree | e186e8d7dfdc0289b2c26d7e6c44f88bf6a7da14 /packages/cli/src/ui/hooks/useCompletion.ts | |
| parent | f379aa833fbd859d1c3795114b3472c4b1a1173f (diff) | |
Make useCompletion.test.ts windows compatible (#4766)
Diffstat (limited to 'packages/cli/src/ui/hooks/useCompletion.ts')
| -rw-r--r-- | packages/cli/src/ui/hooks/useCompletion.ts | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/packages/cli/src/ui/hooks/useCompletion.ts b/packages/cli/src/ui/hooks/useCompletion.ts index f4ebfac3..dc45222d 100644 --- a/packages/cli/src/ui/hooks/useCompletion.ts +++ b/packages/cli/src/ui/hooks/useCompletion.ts @@ -427,13 +427,10 @@ export function useCompletion( }); const suggestions: Suggestion[] = files - .map((file: string) => { - const relativePath = path.relative(cwd, file); - return { - label: relativePath, - value: escapePath(relativePath), - }; - }) + .map((file: string) => ({ + label: file, + value: escapePath(file), + })) .filter((s) => { if (fileDiscoveryService) { return !fileDiscoveryService.shouldIgnoreFile( @@ -475,7 +472,7 @@ export function useCompletion( fetchedSuggestions = await findFilesRecursively( cwd, prefix, - fileDiscoveryService, + null, filterOptions, ); } @@ -518,6 +515,13 @@ export function useCompletion( }); } + // Like glob, we always return forwardslashes, even in windows. + fetchedSuggestions = fetchedSuggestions.map((suggestion) => ({ + ...suggestion, + label: suggestion.label.replace(/\\/g, '/'), + value: suggestion.value.replace(/\\/g, '/'), + })); + // Sort by depth, then directories first, then alphabetically fetchedSuggestions.sort((a, b) => { const depthA = (a.label.match(/\//g) || []).length; |
