diff --git a/src/vs/workbench/contrib/terminal/browser/terminalEditor.ts b/src/vs/workbench/contrib/terminal/browser/terminalEditor.ts index 23719c3bb7655..0318448425ab8 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalEditor.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalEditor.ts @@ -85,7 +85,9 @@ export class TerminalEditor extends EditorPane { override clearInput(): void { super.clearInput(); - this._editorInput?.terminalInstance?.detachFromElement(); + if (this._overflowGuardElement && this._editorInput?.terminalInstance?.domElement.parentElement === this._overflowGuardElement) { + this._editorInput.terminalInstance?.detachFromElement(); + } this._editorInput = undefined; } @@ -188,7 +190,11 @@ export class TerminalEditor extends EditorPane { } layout(dimension: dom.Dimension): void { - this._editorInput?.terminalInstance?.layout(dimension); + const instance = this._editorInput?.terminalInstance; + if (instance) { + instance.attachToElement(this._overflowGuardElement!); + instance.layout(dimension); + } this._lastDimension = dimension; }