From c843a8ad8c41f8150a3564c223dcd47aaf7562c7 Mon Sep 17 00:00:00 2001 From: Simon Siefke Date: Fri, 19 Dec 2025 17:58:13 +0300 Subject: [PATCH] fix: memory leak in terminal editor (#279088) --- src/vs/workbench/contrib/terminal/browser/terminalEditor.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/vs/workbench/contrib/terminal/browser/terminalEditor.ts b/src/vs/workbench/contrib/terminal/browser/terminalEditor.ts index 0bbc6c9e896..8b40d469375 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalEditor.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalEditor.ts @@ -47,6 +47,8 @@ export class TerminalEditor extends EditorPane { private readonly _newDropdown: MutableDisposable = this._register(new MutableDisposable()); + private readonly _sessionDisposables = this._register(new DisposableStore()); + private readonly _disposableStore = this._register(new DisposableStore()); constructor( @@ -84,13 +86,14 @@ export class TerminalEditor extends EditorPane { // since the editor does not monitor focus changes, for ex. between the terminal // panel and the editors, this is needed so that the active instance gets set // when focus changes between them. - this._register(this._editorInput.terminalInstance.onDidFocus(() => this._setActiveInstance())); + this._sessionDisposables.add(this._editorInput.terminalInstance.onDidFocus(() => this._setActiveInstance())); this._editorInput.setCopyLaunchConfig(this._editorInput.terminalInstance.shellLaunchConfig); } } override clearInput(): void { super.clearInput(); + this._sessionDisposables.clear(); if (this._overflowGuardElement && this._editorInput?.terminalInstance?.domElement.parentElement === this._overflowGuardElement) { this._editorInput.terminalInstance?.detachFromElement(); }