+
diff --git a/src/sql/workbench/contrib/notebook/browser/notebook.component.ts b/src/sql/workbench/contrib/notebook/browser/notebook.component.ts
index 648a50db76..b660225e9e 100644
--- a/src/sql/workbench/contrib/notebook/browser/notebook.component.ts
+++ b/src/sql/workbench/contrib/notebook/browser/notebook.component.ts
@@ -297,7 +297,6 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe
public selectCell(cell: ICellModel) {
if (!this.model.activeCell || this.model.activeCell.id !== cell.id) {
this.model.updateActiveCell(cell);
- this.detectChanges();
}
}
@@ -340,7 +339,10 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe
public unselectActiveCell() {
this.model.updateActiveCell(undefined);
- this.detectChanges();
+ }
+
+ public updateActiveCell(cell: ICellModel) {
+ this._model.updateActiveCell(cell);
}
// Handles double click to edit icon change
@@ -446,6 +448,7 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe
this._register(this._model.contentChanged((change) => this.handleContentChanged(change)));
this._register(this._model.onProviderIdChange((provider) => this.handleProviderIdChanged(provider)));
this._register(this._model.kernelChanged((kernelArgs) => this.handleKernelChanged(kernelArgs)));
+ this._register(this._model.onActiveCellChanged(() => this.detectChanges()));
this._register(this._model.onCellTypeChanged(() => this.detectChanges()));
this._register(this._model.layoutChanged(() => this.detectChanges()));
this._register(this.model.onScroll.event(() => this._onScroll.fire()));
diff --git a/src/sql/workbench/services/notebook/browser/models/cell.ts b/src/sql/workbench/services/notebook/browser/models/cell.ts
index 48140bbc6f..fbff21764b 100644
--- a/src/sql/workbench/services/notebook/browser/models/cell.ts
+++ b/src/sql/workbench/services/notebook/browser/models/cell.ts
@@ -46,6 +46,7 @@ export interface QueryResultId {
export class CellModel extends Disposable implements ICellModel {
public id: string;
+ public cellLabel: string;
private _cellType: nb.CellType;
private _source: string | string[];
@@ -120,6 +121,11 @@ export class CellModel extends Disposable implements ICellModel {
}
// if the fromJson() method was already called and _cellGuid was previously set, don't generate another UUID unnecessarily
this._cellGuid = this._cellGuid || generateUuid();
+ if (this._cellType === 'code') {
+ this.cellLabel = localize('codeCellLabel', "Code Cell {0}", this.id);
+ } else {
+ this.cellLabel = localize('mdCellLabel', "Markdown Cell {0}", this.id);
+ }
this.createUri();
this.populatePropertiesFromSettings();
}
diff --git a/src/sql/workbench/services/notebook/browser/models/modelInterfaces.ts b/src/sql/workbench/services/notebook/browser/models/modelInterfaces.ts
index 8c7eddf413..4c2ca7739a 100644
--- a/src/sql/workbench/services/notebook/browser/models/modelInterfaces.ts
+++ b/src/sql/workbench/services/notebook/browser/models/modelInterfaces.ts
@@ -499,6 +499,7 @@ export interface ITableUpdatedEvent {
export interface ICellModel {
cellUri: URI;
id: string;
+ cellLabel: string;
readonly language: string;
readonly displayLanguage: string;
readonly cellGuid: string;
diff --git a/src/sql/workbench/services/notebook/browser/models/notebookModel.ts b/src/sql/workbench/services/notebook/browser/models/notebookModel.ts
index 1cf6065e6c..c72bf28daa 100644
--- a/src/sql/workbench/services/notebook/browser/models/notebookModel.ts
+++ b/src/sql/workbench/services/notebook/browser/models/notebookModel.ts
@@ -802,16 +802,18 @@ export class NotebookModel extends Disposable implements INotebookModel {
}
public updateActiveCell(cell?: ICellModel, isEditMode: boolean = false): void {
- if (this._activeCell) {
- this._activeCell.active = false;
- this._activeCell.isEditMode = false;
+ if (this._activeCell !== cell) {
+ if (this._activeCell) {
+ this._activeCell.active = false;
+ this._activeCell.isEditMode = false;
+ }
+ this._activeCell = cell;
+ if (this._activeCell) {
+ this._activeCell.active = true;
+ this._activeCell.isEditMode = isEditMode;
+ }
+ this._onActiveCellChanged.fire(cell);
}
- this._activeCell = cell;
- if (this._activeCell) {
- this._activeCell.active = true;
- this._activeCell.isEditMode = isEditMode;
- }
- this._onActiveCellChanged.fire(cell);
}
public convertCellType(cell: ICellModel, addToUndoStack: boolean = true): void {