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