diff --git a/src/sql/workbench/contrib/notebook/browser/cellViews/textCell.component.ts b/src/sql/workbench/contrib/notebook/browser/cellViews/textCell.component.ts index e1beaac1e0..7522fdc619 100644 --- a/src/sql/workbench/contrib/notebook/browser/cellViews/textCell.component.ts +++ b/src/sql/workbench/contrib/notebook/browser/cellViews/textCell.component.ts @@ -93,6 +93,7 @@ export class TextCellComponent extends CellView implements OnInit, OnChanges { public readonly onDidClickLink = this._onDidClickLink.event; public previewFeaturesEnabled: boolean = false; public doubleClickEditEnabled: boolean; + private _highlightRange: NotebookRange; constructor( @Inject(forwardRef(() => ChangeDetectorRef)) private _changeRef: ChangeDetectorRef, @@ -238,6 +239,7 @@ export class TextCellComponent extends CellView implements OnInit, OnChanges { outputElement.style.lineHeight = this.markdownPreviewLineHeight.toString(); this.cellModel.renderedOutputTextContent = this.getRenderedTextOutput(); outputElement.focus(); + this.addDecoration(); } } } @@ -345,15 +347,18 @@ export class TextCellComponent extends CellView implements OnInit, OnChanges { public deltaDecorations(newDecorationRange: NotebookRange, oldDecorationRange: NotebookRange): void { if (oldDecorationRange) { + this._highlightRange = oldDecorationRange === this._highlightRange ? undefined : this._highlightRange; this.removeDecoration(oldDecorationRange); } if (newDecorationRange) { + this._highlightRange = newDecorationRange; this.addDecoration(newDecorationRange); } } - private addDecoration(range: NotebookRange): void { + private addDecoration(range?: NotebookRange): void { + range = range ?? this._highlightRange; if (range && this.output && this.output.nativeElement) { let markAllOccurances = new Mark(this.output.nativeElement); // to highlight all occurances in the element. let elements = this.getHtmlElements();