diff --git a/src/sql/workbench/contrib/notebook/browser/models/notebookInput.ts b/src/sql/workbench/contrib/notebook/browser/models/notebookInput.ts index b2b346d4f0..334a799b99 100644 --- a/src/sql/workbench/contrib/notebook/browser/models/notebookInput.ts +++ b/src/sql/workbench/contrib/notebook/browser/models/notebookInput.ts @@ -300,7 +300,7 @@ export abstract class NotebookInput extends EditorInput { private async setTrustForNewEditor(newInput: IEditorInput | undefined): Promise { let model = this._model.getNotebookModel(); - if (model?.trustedMode && newInput?.resource !== this.resource) { + if (model?.trustedMode && newInput && newInput.resource !== this.resource) { await this.notebookService.serializeNotebookStateChange(newInput.resource, NotebookChangeType.Saved, undefined, true); } }