diff --git a/src/sql/parts/notebook/notebook.component.ts b/src/sql/parts/notebook/notebook.component.ts index cc845a3a1f..eb88ef74e2 100644 --- a/src/sql/parts/notebook/notebook.component.ts +++ b/src/sql/parts/notebook/notebook.component.ts @@ -171,7 +171,7 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe } this._model.activeCell = cell; this._model.activeCell.active = true; - this._changeRef.detectChanges(); + this.detectChanges(); } } @@ -180,7 +180,7 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe this.model.activeCell.active = false; this.model.activeCell = undefined; } - this._changeRef.detectChanges(); + this.detectChanges(); } // Add cell based on cell type @@ -195,7 +195,7 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe cell.trustedMode = isTrusted; }); //TODO: Handle dirty for trust? - this._changeRef.detectChanges(); + this.detectChanges(); } public onKeyDown(event) { @@ -235,7 +235,7 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe private setLoading(isLoading: boolean): void { this.isLoading = isLoading; - this._changeRef.detectChanges(); + this.detectChanges(); } private async loadModel(): Promise { @@ -269,7 +269,7 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe this.updateToolbarComponents(this._model.trustedMode); this._modelRegisteredDeferred.resolve(this._model); model.backgroundStartSession(); - this._changeRef.detectChanges(); + this.detectChanges(); } private async awaitNonDefaultProvider(): Promise { @@ -322,7 +322,7 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe private handleContentChanged(change: NotebookContentChange) { // Note: for now we just need to set dirty state and refresh the UI. - this._changeRef.detectChanges(); + this.detectChanges(); } private handleProviderIdChanged(providerId: string) { @@ -497,6 +497,12 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe this.addPrimaryContributedActions(primary); } + private detectChanges(): void { + if (!(this._changeRef['destroyed'])) { + this._changeRef.detectChanges(); + } + } + private addPrimaryContributedActions(primary: IAction[]) { for (let action of primary) { // Need to ensure that we don't add the same action multiple times