From 791caebcc51dea3326bbabc449d2539217dbef14 Mon Sep 17 00:00:00 2001 From: Daniel Gary Date: Fri, 7 May 2021 15:17:17 -0500 Subject: [PATCH] use title for terminal selection --- src/vs/workbench/api/node/extHostDebugService.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/vs/workbench/api/node/extHostDebugService.ts b/src/vs/workbench/api/node/extHostDebugService.ts index 12e894b4960..b74152fe2c7 100644 --- a/src/vs/workbench/api/node/extHostDebugService.ts +++ b/src/vs/workbench/api/node/extHostDebugService.ts @@ -82,8 +82,10 @@ export class ExtHostDebugService extends ExtHostDebugServiceBase { const shell = this._terminalService.getDefaultShell(true, configProvider); const shellArgs = this._terminalService.getDefaultShellArgs(true, configProvider); + const terminalName = args.title || nls.localize('debug.terminal.title', "debuggee"); + const shellConfig = JSON.stringify({ shell, shellArgs }); - let terminal = await this._integratedTerminalInstances.checkout(shellConfig); + let terminal = await this._integratedTerminalInstances.checkout(shellConfig, terminalName); let cwdForPrepareCommand: string | undefined; let giveShellTimeToInitialize = false; @@ -93,7 +95,7 @@ export class ExtHostDebugService extends ExtHostDebugServiceBase { shellPath: shell, shellArgs: shellArgs, cwd: args.cwd, - name: args.title || nls.localize('debug.terminal.title', "debuggee"), + name: terminalName, }; giveShellTimeToInitialize = true; terminal = this._terminalService.createTerminalFromOptions(options, true); @@ -157,9 +159,15 @@ class DebugTerminalCollection { private _terminalInstances = new Map(); - public async checkout(config: string) { + public async checkout(config: string, name: string) { const entries = [...this._terminalInstances.entries()]; const promises = entries.map(([terminal, termInfo]) => createCancelablePromise(async ct => { + + // Only allow terminals that match the title. See #123189 + if (terminal.name !== name) { + return null; + } + if (termInfo.lastUsedAt !== -1 && await hasChildProcesses(await terminal.processId)) { return null; }