request folders/files when appropriate (#236370)

fix #236368
pull/235880/head^2
Megan Rogge 2024-12-17 11:10:39 -06:00 committed by GitHub
parent 639c4c8d1e
commit b4c9953da4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 11 additions and 10 deletions

View File

@ -328,16 +328,6 @@ export async function getCompletionItemsFromSpecs(specs: Fig.Spec[], terminalCon
}
}
}
const shouldShowCommands = !terminalContext.commandLine.substring(0, terminalContext.cursorPosition).trimStart().includes(' ');
if (shouldShowCommands && (filesRequested === foldersRequested)) {
// Include builitin/available commands in the results
const labels = new Set(items.map(i => i.label));
for (const command of availableCommands) {
if (!labels.has(command)) {
items.push(createCompletionItem(terminalContext.cursorPosition, prefix, command));
}
}
}
const shouldShowResourceCompletions =
(
@ -351,6 +341,17 @@ export async function getCompletionItemsFromSpecs(specs: Fig.Spec[], terminalCon
// and neither files nor folders are going to be requested (for a specific spec's argument)
&& (!filesRequested && !foldersRequested);
const shouldShowCommands = !terminalContext.commandLine.substring(0, terminalContext.cursorPosition).trimStart().includes(' ');
if (shouldShowCommands && (filesRequested === foldersRequested)) {
// Include builitin/available commands in the results
const labels = new Set(items.map(i => i.label));
for (const command of availableCommands) {
if (!labels.has(command)) {
items.push(createCompletionItem(terminalContext.cursorPosition, prefix, command));
}
}
}
if (shouldShowResourceCompletions) {
filesRequested = true;
foldersRequested = true;