From b4c9953da47ea1a2061397303db782bd67040fb7 Mon Sep 17 00:00:00 2001 From: Megan Rogge Date: Tue, 17 Dec 2024 11:10:39 -0600 Subject: [PATCH] request folders/files when appropriate (#236370) fix #236368 --- .../src/terminalSuggestMain.ts | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/extensions/terminal-suggest/src/terminalSuggestMain.ts b/extensions/terminal-suggest/src/terminalSuggestMain.ts index 5071c4c79ce..4acd5b59f8a 100644 --- a/extensions/terminal-suggest/src/terminalSuggestMain.ts +++ b/extensions/terminal-suggest/src/terminalSuggestMain.ts @@ -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;