@@ -251,7 +251,6 @@ export async function getCompletionItemsFromSpecs(specs: Fig.Spec[], terminalCon
251
251
const items : vscode . TerminalCompletionItem [ ] = [ ] ;
252
252
let filesRequested = false ;
253
253
let foldersRequested = false ;
254
- let specificSuggestionsProvided = false ;
255
254
const firstCommand = getFirstCommand ( terminalContext . commandLine ) ;
256
255
for ( const spec of specs ) {
257
256
const specLabels = getLabel ( spec ) ;
@@ -297,15 +296,13 @@ export async function getCompletionItemsFromSpecs(specs: Fig.Spec[], terminalCon
297
296
if ( ! argsCompletions ) {
298
297
continue ;
299
298
}
300
- specificSuggestionsProvided = true ;
301
299
const argCompletions = argsCompletions . items ;
302
300
foldersRequested = foldersRequested || argsCompletions . foldersRequested ;
303
301
filesRequested = filesRequested || argsCompletions . filesRequested ;
304
302
let cwd : vscode . Uri | undefined ;
305
303
if ( shellIntegrationCwd && ( filesRequested || foldersRequested ) ) {
306
304
cwd = await resolveCwdFromPrefix ( prefix , shellIntegrationCwd ) ?? shellIntegrationCwd ;
307
305
}
308
- specificSuggestionsProvided = argsCompletions . specificSuggestionsProvided ;
309
306
return { items : argCompletions , filesRequested, foldersRequested, cwd } ;
310
307
}
311
308
}
@@ -322,17 +319,17 @@ export async function getCompletionItemsFromSpecs(specs: Fig.Spec[], terminalCon
322
319
continue ;
323
320
}
324
321
items . push ( ...argsCompletions . items ) ;
325
- specificSuggestionsProvided = argsCompletions . specificSuggestionsProvided ;
326
322
filesRequested = filesRequested || argsCompletions . filesRequested ;
327
323
foldersRequested = foldersRequested || argsCompletions . foldersRequested ;
328
324
}
329
325
}
330
326
}
331
-
332
- if ( ! specificSuggestionsProvided && ( filesRequested === foldersRequested ) ) {
327
+ const shouldShowCommands = ! terminalContext . commandLine . substring ( 0 , terminalContext . cursorPosition ) . trimStart ( ) . includes ( ' ' ) ;
328
+ if ( shouldShowCommands && ( filesRequested === foldersRequested ) ) {
333
329
// Include builitin/available commands in the results
330
+ const labels = new Set ( items . map ( i => i . label ) ) ;
334
331
for ( const command of availableCommands ) {
335
- if ( ( ! terminalContext . commandLine . trim ( ) || firstCommand && command . startsWith ( firstCommand ) ) && ! items . find ( item => item . label === command ) ) {
332
+ if ( ! labels . has ( command ) ) {
336
333
items . push ( createCompletionItem ( terminalContext . cursorPosition , prefix , command ) ) ;
337
334
}
338
335
}
@@ -361,7 +358,7 @@ export async function getCompletionItemsFromSpecs(specs: Fig.Spec[], terminalCon
361
358
return { items, filesRequested, foldersRequested, cwd } ;
362
359
}
363
360
364
- function getCompletionItemsFromArgs ( args : Fig . SingleOrArray < Fig . Arg > | undefined , currentPrefix : string , terminalContext : { commandLine : string ; cursorPosition : number } ) : { items : vscode . TerminalCompletionItem [ ] ; filesRequested : boolean ; foldersRequested : boolean ; specificSuggestionsProvided : boolean } | undefined {
361
+ function getCompletionItemsFromArgs ( args : Fig . SingleOrArray < Fig . Arg > | undefined , currentPrefix : string , terminalContext : { commandLine : string ; cursorPosition : number } ) : { items : vscode . TerminalCompletionItem [ ] ; filesRequested : boolean ; foldersRequested : boolean } | undefined {
365
362
if ( ! args ) {
366
363
return ;
367
364
}
@@ -395,7 +392,7 @@ function getCompletionItemsFromArgs(args: Fig.SingleOrArray<Fig.Arg> | undefined
395
392
continue ;
396
393
}
397
394
if ( ! arg . isVariadic && twoWordsBefore === suggestionLabel && wordBefore ?. trim ( ) === '' ) {
398
- return { items : [ ] , filesRequested, foldersRequested, specificSuggestionsProvided : false } ;
395
+ return { items : [ ] , filesRequested, foldersRequested } ;
399
396
}
400
397
if ( suggestionLabel && suggestionLabel . startsWith ( currentPrefix . trim ( ) ) ) {
401
398
const description = typeof suggestion !== 'string' ? suggestion . description : '' ;
@@ -404,11 +401,11 @@ function getCompletionItemsFromArgs(args: Fig.SingleOrArray<Fig.Arg> | undefined
404
401
}
405
402
}
406
403
if ( items . length ) {
407
- return { items, filesRequested, foldersRequested, specificSuggestionsProvided : true } ;
404
+ return { items, filesRequested, foldersRequested } ;
408
405
}
409
406
}
410
407
}
411
- return { items, filesRequested, foldersRequested, specificSuggestionsProvided : false } ;
408
+ return { items, filesRequested, foldersRequested } ;
412
409
}
413
410
414
411
function osIsWindows ( ) : boolean {
0 commit comments