diff --git a/src/vs/platform/terminal/common/terminal.ts b/src/vs/platform/terminal/common/terminal.ts index 1b9abbd2e70..7960d7aec9a 100644 --- a/src/vs/platform/terminal/common/terminal.ts +++ b/src/vs/platform/terminal/common/terminal.ts @@ -261,7 +261,7 @@ export interface IPtyService { updateTitle(id: number, title: string, titleSource: TitleEventSource): Promise; updateIcon(id: number, icon: TerminalIcon, color?: string): Promise; getDefaultSystemShell(osOverride?: OperatingSystem): Promise; - getProfiles?(profiles: unknown, defaultProfile: unknown, includeDetectedProfiles?: boolean): Promise; + getProfiles?(workspaceId: string, profiles: unknown, defaultProfile: unknown, includeDetectedProfiles?: boolean): Promise; getEnvironment(): Promise; getWslPath(original: string): Promise; setTerminalLayoutInfo(args: ISetTerminalLayoutInfoArgs): Promise; @@ -271,6 +271,7 @@ export interface IPtyService { export interface IRequestResolveVariablesEvent { id: number; + workspaceId: string; originalText: string[]; } diff --git a/src/vs/platform/terminal/node/ptyHostService.ts b/src/vs/platform/terminal/node/ptyHostService.ts index 9e00f75b520..eee9e395496 100644 --- a/src/vs/platform/terminal/node/ptyHostService.ts +++ b/src/vs/platform/terminal/node/ptyHostService.ts @@ -222,8 +222,8 @@ export class PtyHostService extends Disposable implements IPtyService { getDefaultSystemShell(osOverride?: OperatingSystem): Promise { return this._proxy.getDefaultSystemShell(osOverride); } - async getProfiles(profiles: unknown, defaultProfile: unknown, includeDetectedProfiles: boolean = false): Promise { - 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 { + return detectAvailableProfiles(profiles, defaultProfile, includeDetectedProfiles, this._configurationService, undefined, this._logService, this._resolveVariables.bind(this, workspaceId)); } getEnvironment(): Promise { return this._proxy.getEnvironment(); @@ -310,11 +310,11 @@ export class PtyHostService extends Disposable implements IPtyService { } private _pendingResolveVariablesRequests: Map void> = new Map(); - private _resolveVariables(text: string[]): Promise { + private _resolveVariables(workspaceId: string, text: string[]): Promise { return new Promise(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[]) { diff --git a/src/vs/workbench/contrib/terminal/browser/remoteTerminalService.ts b/src/vs/workbench/contrib/terminal/browser/remoteTerminalService.ts index ef00813ca78..5f31f3a6803 100644 --- a/src/vs/workbench/contrib/terminal/browser/remoteTerminalService.ts +++ b/src/vs/workbench/contrib/terminal/browser/remoteTerminalService.ts @@ -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[] = e.originalText.map(t => { diff --git a/src/vs/workbench/contrib/terminal/common/remoteTerminalChannel.ts b/src/vs/workbench/contrib/terminal/common/remoteTerminalChannel.ts index ae51b8406a5..e42b31dc91b 100644 --- a/src/vs/workbench/contrib/terminal/common/remoteTerminalChannel.ts +++ b/src/vs/workbench/contrib/terminal/common/remoteTerminalChannel.ts @@ -242,7 +242,7 @@ export class RemoteTerminalChannelClient { return this._channel.call('$getDefaultSystemShell', [osOverride]); } getProfiles(profiles: unknown, defaultProfile: unknown, includeDetectedProfiles?: boolean): Promise { - 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]); diff --git a/src/vs/workbench/contrib/terminal/electron-sandbox/localTerminalService.ts b/src/vs/workbench/contrib/terminal/electron-sandbox/localTerminalService.ts index f54550c65aa..5d64fe4b25e 100644 --- a/src/vs/workbench/contrib/terminal/electron-sandbox/localTerminalService.ts +++ b/src/vs/workbench/contrib/terminal/electron-sandbox/localTerminalService.ts @@ -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[] = 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 {