From 452bd6a0cb3336cb5b4e05cd5d6f13a3ba47719c Mon Sep 17 00:00:00 2001 From: Chris LaFreniere <40371649+chlafreniere@users.noreply.github.com> Date: Fri, 15 May 2020 11:48:11 -0700 Subject: [PATCH] Notebook model ready sooner (#10420) --- .../contrib/notebook/browser/models/notebookInput.ts | 5 +++++ .../workbench/contrib/notebook/browser/notebook.component.ts | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/sql/workbench/contrib/notebook/browser/models/notebookInput.ts b/src/sql/workbench/contrib/notebook/browser/models/notebookInput.ts index 334a799b99..6406ba5db0 100644 --- a/src/sql/workbench/contrib/notebook/browser/models/notebookInput.ts +++ b/src/sql/workbench/contrib/notebook/browser/models/notebookInput.ts @@ -42,6 +42,7 @@ export class NotebookEditorModel extends EditorModel { private _notebookTextFileModel: NotebookTextFileModel; private readonly _onDidChangeDirty: Emitter = this._register(new Emitter()); private _lastEditFullReplacement: boolean; + private _isFirstKernelChange: boolean = true; constructor(public readonly notebookUri: URI, private textEditorModel: ITextFileEditorModel | IUntitledTextEditorModel | ResourceEditorModel, @INotebookService private notebookService: INotebookService, @@ -110,6 +111,10 @@ export class NotebookEditorModel extends EditorModel { } public updateModel(contentChange?: NotebookContentChange, type?: NotebookChangeType): void { + if (type === NotebookChangeType.KernelChanged && this._isFirstKernelChange) { + this._isFirstKernelChange = false; + return; + } this._lastEditFullReplacement = false; if (contentChange && contentChange.changeType === NotebookChangeType.Saved) { // We send the saved events out, so ignore. Otherwise we double-count this as a change diff --git a/src/sql/workbench/contrib/notebook/browser/notebook.component.ts b/src/sql/workbench/contrib/notebook/browser/notebook.component.ts index 75c0b20056..59b3090076 100644 --- a/src/sql/workbench/contrib/notebook/browser/notebook.component.ts +++ b/src/sql/workbench/contrib/notebook/browser/notebook.component.ts @@ -238,10 +238,10 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe private async doLoad(): Promise { try { await this.createModelAndLoadContents(); - await this.setNotebookManager(); - await this.loadModel(); this._modelReadyDeferred.resolve(this._model); this.notebookService.addNotebookEditor(this); + await this.setNotebookManager(); + await this.loadModel(); } catch (error) { if (error) { // Offer to create a file from the error if we have a file not found and the name is valid