@@ -76,7 +76,6 @@ const getShellSpecificGlobals: Map<TerminalShellType, (options: ExecOptionsWithS
76
76
[ TerminalShellType . PowerShell , getPwshGlobals ] ,
77
77
] ) ;
78
78
79
-
80
79
async function getShellGlobals (
81
80
shellType : TerminalShellType ,
82
81
existingCommands ?: Set < string > ,
@@ -106,8 +105,11 @@ async function getShellGlobals(
106
105
shouldRefresh = true ;
107
106
}
108
107
if ( ! shouldRefresh && cached . commands ) {
109
- // Trigger background refresh
110
- void fetchAndCacheShellGlobals ( shellType , existingCommands , machineId , remoteAuthority , true ) ;
108
+ // NOTE: This used to trigger a background refresh in order to ensure all commands
109
+ // are up to date, but this ends up launching way too many processes. Especially on
110
+ // Windows where this caused significant performance issues as processes can block
111
+ // the extension host for several seconds
112
+ // (https://github.com/microsoft/vscode/issues/259343).
111
113
return cached . commands ;
112
114
}
113
115
}
@@ -253,15 +255,14 @@ export async function activate(context: vscode.ExtensionContext) {
253
255
}
254
256
255
257
const commandsInPath = await pathExecutableCache . getExecutablesInPath ( terminal . shellIntegration ?. env ?. value , terminalShellType ) ;
256
- const shellGlobals = await getShellGlobals ( terminalShellType , commandsInPath ?. labels , machineId , remoteAuthority ) ;
258
+ const shellGlobals = await getShellGlobals ( terminalShellType , commandsInPath ?. labels , machineId , remoteAuthority ) ?? [ ] ;
257
259
258
- const shellGlobalsArr = shellGlobals ?? [ ] ;
259
260
if ( ! commandsInPath ?. completionResources ) {
260
261
console . debug ( '#terminalCompletions No commands found in path' ) ;
261
262
return ;
262
263
}
263
264
// Order is important here, add shell globals first so they are prioritized over path commands
264
- const commands = [ ...shellGlobalsArr , ...commandsInPath . completionResources ] ;
265
+ const commands = [ ...shellGlobals , ...commandsInPath . completionResources ] ;
265
266
const currentCommandString = getCurrentCommandAndArgs ( terminalContext . commandLine , terminalContext . cursorPosition , terminalShellType ) ;
266
267
const pathSeparator = isWindows ? '\\' : '/' ;
267
268
const tokenType = getTokenType ( terminalContext , terminalShellType ) ;
@@ -305,6 +306,10 @@ export async function activate(context: vscode.ExtensionContext) {
305
306
}
306
307
} , '/' , '\\' ) ) ;
307
308
await watchPathDirectories ( context , currentTerminalEnv , pathExecutableCache ) ;
309
+
310
+ context . subscriptions . push ( vscode . commands . registerCommand ( 'terminal.integrated.suggest.clearCachedGlobals' , ( ) => {
311
+ cachedGlobals . clear ( ) ;
312
+ } ) ) ;
308
313
}
309
314
310
315
/**
0 commit comments