fix: memory leak in terminal editor (#279088)

This commit is contained in:
Simon Siefke
2025-12-19 17:58:13 +03:00
committed by GitHub
parent ad89fb781a
commit c843a8ad8c

View File

@@ -47,6 +47,8 @@ export class TerminalEditor extends EditorPane {
private readonly _newDropdown: MutableDisposable<DropdownWithPrimaryActionViewItem> = this._register(new MutableDisposable()); private readonly _newDropdown: MutableDisposable<DropdownWithPrimaryActionViewItem> = this._register(new MutableDisposable());
private readonly _sessionDisposables = this._register(new DisposableStore());
private readonly _disposableStore = this._register(new DisposableStore()); private readonly _disposableStore = this._register(new DisposableStore());
constructor( constructor(
@@ -84,13 +86,14 @@ export class TerminalEditor extends EditorPane {
// since the editor does not monitor focus changes, for ex. between the terminal // 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 // panel and the editors, this is needed so that the active instance gets set
// when focus changes between them. // 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); this._editorInput.setCopyLaunchConfig(this._editorInput.terminalInstance.shellLaunchConfig);
} }
} }
override clearInput(): void { override clearInput(): void {
super.clearInput(); super.clearInput();
this._sessionDisposables.clear();
if (this._overflowGuardElement && this._editorInput?.terminalInstance?.domElement.parentElement === this._overflowGuardElement) { if (this._overflowGuardElement && this._editorInput?.terminalInstance?.domElement.parentElement === this._overflowGuardElement) {
this._editorInput.terminalInstance?.detachFromElement(); this._editorInput.terminalInstance?.detachFromElement();
} }