diff --git a/src/vs/workbench/api/node/extHostTerminalService.ts b/src/vs/workbench/api/node/extHostTerminalService.ts index 930b010a09c..6bade2ed5d6 100644 --- a/src/vs/workbench/api/node/extHostTerminalService.ts +++ b/src/vs/workbench/api/node/extHostTerminalService.ts @@ -24,6 +24,7 @@ import type * as vscode from 'vscode'; export class ExtHostTerminalService extends BaseExtHostTerminalService { private _variableResolver: ExtHostVariableResolverService | undefined; + private _variableResolverPromise: Promise; private _lastActiveWorkspace: IWorkspaceFolder | undefined; // TODO: Pull this from main side @@ -45,7 +46,7 @@ export class ExtHostTerminalService extends BaseExtHostTerminalService { getSystemShell(platform.platform, process.env as platform.IProcessEnvironment).then(s => this._defaultShell = s); this._updateLastActiveWorkspace(); - this._updateVariableResolver(); + this._variableResolverPromise = this._updateVariableResolver(); this._registerListeners(); } @@ -116,7 +117,9 @@ export class ExtHostTerminalService extends BaseExtHostTerminalService { private _registerListeners(): void { this._extHostDocumentsAndEditors.onDidChangeActiveTextEditor(() => this._updateLastActiveWorkspace()); - this._extHostWorkspace.onDidChangeWorkspace(() => this._updateVariableResolver()); + this._extHostWorkspace.onDidChangeWorkspace(() => { + this._variableResolverPromise = this._updateVariableResolver(); + }); } private _updateLastActiveWorkspace(): void { @@ -126,15 +129,16 @@ export class ExtHostTerminalService extends BaseExtHostTerminalService { } } - private async _updateVariableResolver(): Promise { + private async _updateVariableResolver(): Promise { const configProvider = await this._extHostConfiguration.getConfigProvider(); const workspaceFolders = await this._extHostWorkspace.getWorkspaceFolders2(); this._variableResolver = new ExtHostVariableResolverService(workspaceFolders || [], this._extHostDocumentsAndEditors, configProvider); + return this._variableResolver; } public async $getAvailableProfiles(quickLaunchOnly: boolean): Promise { const config = await (await this._extHostConfiguration.getConfigProvider()).getConfiguration().get('terminal.integrated'); - return detectAvailableProfiles(quickLaunchOnly, this._logService, config as ITerminalConfiguration, this._variableResolver, this._lastActiveWorkspace); + return detectAvailableProfiles(quickLaunchOnly, this._logService, config as ITerminalConfiguration, await this._variableResolverPromise, this._lastActiveWorkspace); } public async $getDefaultShellAndArgs(useAutomationShell: boolean): Promise { diff --git a/src/vs/workbench/contrib/terminal/node/terminalProfiles.ts b/src/vs/workbench/contrib/terminal/node/terminalProfiles.ts index c47fb560265..07c47fcc800 100644 --- a/src/vs/workbench/contrib/terminal/node/terminalProfiles.ts +++ b/src/vs/workbench/contrib/terminal/node/terminalProfiles.ts @@ -72,19 +72,23 @@ async function transformToTerminalProfiles(entries: IterableIterator<[string, IT const resultProfiles: ITerminalProfile[] = []; for (const [profileName, profile] of entries) { if (profile === null) { continue; } - let paths: string[]; + let originalPaths: string[]; let args: string[] | string | undefined; + if ('source' in profile) { const source = profileSources?.get(profile.source); if (!source) { continue; } - paths = source.paths.slice(); + originalPaths = source.paths; args = source.args; } else { - paths = Array.isArray(profile.path) ? profile.path : [profile.path]; + originalPaths = Array.isArray(profile.path) ? profile.path : [profile.path]; args = profile.args; } + + const paths = originalPaths.slice(); + for (let i = 0; i < paths.length; i++) { paths[i] = variableResolver?.resolve(workspaceFolder, paths[i]) || paths[i]; } @@ -92,7 +96,7 @@ async function transformToTerminalProfiles(entries: IterableIterator<[string, IT if (validatedProfile) { resultProfiles.push(validatedProfile); } else { - logService?.trace('profile not validated', profileName, paths); + logService?.trace('profile not validated', profileName, originalPaths); } } return resultProfiles; @@ -249,7 +253,6 @@ async function validateProfilePaths(label: string, potentialPaths: string[], sta } } } catch (e) { - logService?.info('error', e); // Also try using lstat as some symbolic links on Windows // throw 'permission denied' using 'stat' but don't throw // using 'lstat'