diff --git a/packages/plugin-ext/src/plugin/terminal-ext.ts b/packages/plugin-ext/src/plugin/terminal-ext.ts index 53109cff3765b..891eed6d998ca 100644 --- a/packages/plugin-ext/src/plugin/terminal-ext.ts +++ b/packages/plugin-ext/src/plugin/terminal-ext.ts @@ -189,7 +189,18 @@ export class TerminalServiceExtImpl implements TerminalServiceExt { terminal.deferredProcessId = new Deferred(); terminal.deferredProcessId.resolve(processId); } - const pseudoTerminal = this._pseudoTerminals.get(terminalId.toString()); + + // Switch the pseudoterminal keyed by terminalId to be keyed by terminal ID + const tId = terminalId.toString(); + if (this._pseudoTerminals.has(tId)) { + const pseudo = this._pseudoTerminals.get(tId); + if (pseudo) { + this._pseudoTerminals.set(id, pseudo); + } + this._pseudoTerminals.delete(tId); + } + + const pseudoTerminal = this._pseudoTerminals.get(id); if (pseudoTerminal) { pseudoTerminal.emitOnOpen(cols, rows); }