mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-20 08:47:44 +00:00
Make useCompletion.test.ts windows compatible (#4766)
This commit is contained in:
committed by
GitHub
parent
f379aa833f
commit
3c16429fc4
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user