diff --git a/src/vs/workbench/contrib/notebook/browser/notebookEditor.ts b/src/vs/workbench/contrib/notebook/browser/notebookEditor.ts index 060e809f098..d53d358d119 100644 --- a/src/vs/workbench/contrib/notebook/browser/notebookEditor.ts +++ b/src/vs/workbench/contrib/notebook/browser/notebookEditor.ts @@ -141,6 +141,9 @@ export class NotebookEditor extends BaseEditor { // make sure the editor widget is removed from the view const existingEditorWidgetForInput = NotebookRegistry.getNotebookEditorWidget(this.input as NotebookEditorInput); if (existingEditorWidgetForInput) { + // the editor widget is only referenced by the editor input + // clear its state + existingEditorWidgetForInput?.onWillHide(); existingEditorWidgetForInput?.getDomNode().remove(); existingEditorWidgetForInput?.dispose(); NotebookRegistry.releaseNotebookEditorWidget(this.input as NotebookEditorInput);