File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed
extensions/terminal-suggest/src Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -46,16 +46,26 @@ export async function getFigSuggestions(
46
46
items : [ ] ,
47
47
} ;
48
48
const currentCommand = currentCommandAndArgString . split ( ' ' ) [ 0 ] ;
49
+
50
+ // Assemble a map to allow O(1) access to the available command from a spec
51
+ // label. The label does not include an extension on Windows.
52
+ const specLabelToAvailableCommandMap = new Map < string , ICompletionResource > ( ) ;
53
+ for ( const command of availableCommands ) {
54
+ let label = typeof command . label === 'string' ? command . label : command . label . label ;
55
+ if ( osIsWindows ( ) ) {
56
+ label = removeAnyFileExtension ( label ) ;
57
+ }
58
+ specLabelToAvailableCommandMap . set ( label , command ) ;
59
+ }
60
+
49
61
for ( const spec of specs ) {
50
62
const specLabels = getFigSuggestionLabel ( spec ) ;
51
63
52
64
if ( ! specLabels ) {
53
65
continue ;
54
66
}
55
67
for ( const specLabel of specLabels ) {
56
- const availableCommand = ( osIsWindows ( )
57
- ? availableCommands . find ( command => ( typeof command . label === 'string' ? command . label : command . label . label ) . match ( new RegExp ( `${ specLabel } (\\.[^ ]+)?$` ) ) )
58
- : availableCommands . find ( command => ( typeof command . label === 'string' ? command . label : command . label . label ) === ( specLabel ) ) ) ;
68
+ const availableCommand = specLabelToAvailableCommandMap . get ( specLabel ) ;
59
69
if ( ! availableCommand || ( token && token . isCancellationRequested ) ) {
60
70
continue ;
61
71
}
Original file line number Diff line number Diff line change @@ -295,6 +295,7 @@ export async function activate(context: vscode.ExtensionContext) {
295
295
}
296
296
}
297
297
298
+
298
299
if ( terminal . shellIntegration ?. cwd && ( result . filesRequested || result . foldersRequested ) ) {
299
300
return new vscode . TerminalCompletionList ( result . items , {
300
301
filesRequested : result . filesRequested ,
You can’t perform that action at this time.
0 commit comments