mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-30 01:25:38 -05:00
Highlight all matches in Notebook on Find (#15562)
* iterate over every cell and highlight ranges. * fix yellow for all matches and orange for current * fix * avoid duplicate deltaDecorations call * initialize on declare
This commit is contained in:
@@ -154,14 +154,40 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe
|
||||
return editors;
|
||||
}
|
||||
|
||||
public deltaDecorations(newDecorationRange: NotebookRange, oldDecorationRange: NotebookRange): void {
|
||||
if (newDecorationRange && newDecorationRange.cell && newDecorationRange.cell.cellType === 'markdown') {
|
||||
let cell = this.cellEditors.filter(c => c.cellGuid() === newDecorationRange.cell.cellGuid);
|
||||
cell[cell.length - 1].deltaDecorations(newDecorationRange, undefined);
|
||||
public deltaDecorations(newDecorationsRange: NotebookRange | NotebookRange[], oldDecorationsRange: NotebookRange | NotebookRange[]): void {
|
||||
if (oldDecorationsRange) {
|
||||
if (Array.isArray(oldDecorationsRange)) {
|
||||
let decoratedCells: string[] = [];
|
||||
oldDecorationsRange.forEach(oldDecorationRange => {
|
||||
if (oldDecorationRange.cell.cellType === 'markdown' && decoratedCells.indexOf(oldDecorationRange.cell.cellGuid) === -1) {
|
||||
let cell = this.cellEditors.filter(c => c.cellGuid() === oldDecorationRange.cell.cellGuid);
|
||||
cell[cell.length - 1].deltaDecorations(undefined, [oldDecorationRange]);
|
||||
decoratedCells.push(...oldDecorationRange.cell.cellGuid);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if (oldDecorationsRange.cell.cellType === 'markdown') {
|
||||
let cell = this.cellEditors.filter(c => c.cellGuid() === oldDecorationsRange.cell.cellGuid);
|
||||
cell[cell.length - 1].deltaDecorations(undefined, oldDecorationsRange);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (oldDecorationRange && oldDecorationRange.cell && oldDecorationRange.cell.cellType === 'markdown') {
|
||||
let cell = this.cellEditors.filter(c => c.cellGuid() === oldDecorationRange.cell.cellGuid);
|
||||
cell[cell.length - 1].deltaDecorations(undefined, oldDecorationRange);
|
||||
if (newDecorationsRange) {
|
||||
if (Array.isArray(newDecorationsRange)) {
|
||||
let decoratedCells: string[] = [];
|
||||
newDecorationsRange.forEach(newDecorationRange => {
|
||||
if (newDecorationRange.cell.cellType === 'markdown' && decoratedCells.indexOf(newDecorationRange.cell.cellGuid) === -1) {
|
||||
let cell = this.cellEditors.filter(c => c.cellGuid() === newDecorationRange.cell.cellGuid);
|
||||
cell[cell.length - 1].deltaDecorations([newDecorationRange], undefined);
|
||||
decoratedCells.push(...newDecorationRange.cell.cellGuid);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if (newDecorationsRange.cell.cellType === 'markdown') {
|
||||
let cell = this.cellEditors.filter(c => c.cellGuid() === newDecorationsRange.cell.cellGuid);
|
||||
cell[cell.length - 1].deltaDecorations(newDecorationsRange, undefined);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user