Skip to content

Commit

Permalink
Fix #119700 fix #119731 fix #119701
Browse files Browse the repository at this point in the history
Co-authored-by: Daniel Imms <daimms@microsoft.com>
  • Loading branch information
meganrogge committed Mar 24, 2021
1 parent 51c4031 commit ddb7709
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
12 changes: 8 additions & 4 deletions src/vs/workbench/api/node/extHostTerminalService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import type * as vscode from 'vscode';
export class ExtHostTerminalService extends BaseExtHostTerminalService {

private _variableResolver: ExtHostVariableResolverService | undefined;
private _variableResolverPromise: Promise<ExtHostVariableResolverService>;
private _lastActiveWorkspace: IWorkspaceFolder | undefined;

// TODO: Pull this from main side
Expand All @@ -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();
}

Expand Down Expand Up @@ -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 {
Expand All @@ -126,15 +129,16 @@ export class ExtHostTerminalService extends BaseExtHostTerminalService {
}
}

private async _updateVariableResolver(): Promise<void> {
private async _updateVariableResolver(): Promise<ExtHostVariableResolverService> {
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<ITerminalProfile[]> {
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<IShellAndArgsDto> {
Expand Down
13 changes: 8 additions & 5 deletions src/vs/workbench/contrib/terminal/node/terminalProfiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,27 +72,31 @@ 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];
}
const validatedProfile = await validateProfilePaths(profileName, paths, statProvider, args, logService);
if (validatedProfile) {
resultProfiles.push(validatedProfile);
} else {
logService?.trace('profile not validated', profileName, paths);
logService?.trace('profile not validated', profileName, originalPaths);
}
}
return resultProfiles;
Expand Down Expand Up @@ -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'
Expand Down

0 comments on commit ddb7709

Please sign in to comment.