Respect var resolve requests only for the given workspace

Fixes #127062
This commit is contained in:
Daniel Imms 2021-07-07 05:38:59 -07:00
parent 776bd3d6d0
commit b0cde4e271
5 changed files with 17 additions and 8 deletions

View file

@ -261,7 +261,7 @@ export interface IPtyService {
updateTitle(id: number, title: string, titleSource: TitleEventSource): Promise<void>;
updateIcon(id: number, icon: TerminalIcon, color?: string): Promise<void>;
getDefaultSystemShell(osOverride?: OperatingSystem): Promise<string>;
getProfiles?(profiles: unknown, defaultProfile: unknown, includeDetectedProfiles?: boolean): Promise<ITerminalProfile[]>;
getProfiles?(workspaceId: string, profiles: unknown, defaultProfile: unknown, includeDetectedProfiles?: boolean): Promise<ITerminalProfile[]>;
getEnvironment(): Promise<IProcessEnvironment>;
getWslPath(original: string): Promise<string>;
setTerminalLayoutInfo(args: ISetTerminalLayoutInfoArgs): Promise<void>;
@ -271,6 +271,7 @@ export interface IPtyService {
export interface IRequestResolveVariablesEvent {
id: number;
workspaceId: string;
originalText: string[];
}

View file

@ -222,8 +222,8 @@ export class PtyHostService extends Disposable implements IPtyService {
getDefaultSystemShell(osOverride?: OperatingSystem): Promise<string> {
return this._proxy.getDefaultSystemShell(osOverride);
}
async getProfiles(profiles: unknown, defaultProfile: unknown, includeDetectedProfiles: boolean = false): Promise<ITerminalProfile[]> {
return detectAvailableProfiles(profiles, defaultProfile, includeDetectedProfiles, this._configurationService, undefined, this._logService, this._resolveVariables.bind(this));
async getProfiles(workspaceId: string, profiles: unknown, defaultProfile: unknown, includeDetectedProfiles: boolean = false): Promise<ITerminalProfile[]> {
return detectAvailableProfiles(profiles, defaultProfile, includeDetectedProfiles, this._configurationService, undefined, this._logService, this._resolveVariables.bind(this, workspaceId));
}
getEnvironment(): Promise<IProcessEnvironment> {
return this._proxy.getEnvironment();
@ -310,11 +310,11 @@ export class PtyHostService extends Disposable implements IPtyService {
}
private _pendingResolveVariablesRequests: Map<number, (resolved: string[]) => void> = new Map();
private _resolveVariables(text: string[]): Promise<string[]> {
private _resolveVariables(workspaceId: string, text: string[]): Promise<string[]> {
return new Promise<string[]>(resolve => {
const id = ++lastResolveVariablesRequestId;
this._pendingResolveVariablesRequests.set(id, resolve);
this._onPtyHostRequestResolveVariables.fire({ id, originalText: text });
this._onPtyHostRequestResolveVariables.fire({ id, workspaceId, originalText: text });
});
}
async acceptPtyHostResolvedVariables(id: number, resolved: string[]) {

View file

@ -134,6 +134,10 @@ export class RemoteTerminalService extends Disposable implements IRemoteTerminal
}));
}
this._register(channel.onPtyHostRequestResolveVariables(async e => {
// Only answer requests for this workspace
if (e.workspaceId !== workspaceContextService.getWorkspace().id) {
return;
}
const activeWorkspaceRootUri = historyService.getLastActiveWorkspaceRoot(Schemas.vscodeRemote);
const lastActiveWorkspaceRoot = activeWorkspaceRootUri ? withNullAsUndefined(workspaceContextService.getWorkspaceFolder(activeWorkspaceRootUri)) : undefined;
const resolveCalls: Promise<string>[] = e.originalText.map(t => {

View file

@ -242,7 +242,7 @@ export class RemoteTerminalChannelClient {
return this._channel.call('$getDefaultSystemShell', [osOverride]);
}
getProfiles(profiles: unknown, defaultProfile: unknown, includeDetectedProfiles?: boolean): Promise<ITerminalProfile[]> {
return this._channel.call('$getProfiles', [profiles, defaultProfile, includeDetectedProfiles]);
return this._channel.call('$getProfiles', [this._workspaceContextService.getWorkspace().id, profiles, defaultProfile, includeDetectedProfiles]);
}
acceptPtyHostResolvedVariables(id: number, resolved: string[]) {
return this._channel.call('$acceptPtyHostResolvedVariables', [id, resolved]);

View file

@ -45,7 +45,7 @@ export class LocalTerminalService extends Disposable implements ILocalTerminalSe
@INotificationService notificationService: INotificationService,
@IShellEnvironmentService private readonly _shellEnvironmentService: IShellEnvironmentService,
@IConfigurationResolverService configurationResolverService: IConfigurationResolverService,
@IHistoryService historyService: IHistoryService
@IHistoryService historyService: IHistoryService,
) {
super();
@ -106,6 +106,10 @@ export class LocalTerminalService extends Disposable implements ILocalTerminalSe
}
if (this._localPtyService.onPtyHostRequestResolveVariables) {
this._register(this._localPtyService.onPtyHostRequestResolveVariables(async e => {
// Only answer requests for this workspace
if (e.workspaceId !== this._workspaceContextService.getWorkspace().id) {
return;
}
const activeWorkspaceRootUri = historyService.getLastActiveWorkspaceRoot(Schemas.file);
const lastActiveWorkspaceRoot = activeWorkspaceRootUri ? withNullAsUndefined(this._workspaceContextService.getWorkspaceFolder(activeWorkspaceRootUri)) : undefined;
const resolveCalls: Promise<string>[] = e.originalText.map(t => {
@ -157,7 +161,7 @@ export class LocalTerminalService extends Disposable implements ILocalTerminalSe
}
async getProfiles(profiles: unknown, defaultProfile: unknown, includeDetectedProfiles?: boolean) {
return this._localPtyService.getProfiles?.(profiles, defaultProfile, includeDetectedProfiles) || [];
return this._localPtyService.getProfiles?.(this._workspaceContextService.getWorkspace().id, profiles, defaultProfile, includeDetectedProfiles) || [];
}
async getEnvironment(): Promise<IProcessEnvironment> {