Fix/search text cell on edit (#9685)

* find in text cell changes

* remove prev decorations

* update find index on cell edit

* added test

* addressed comments

* emit error
This commit is contained in:
Maddy
2020-03-25 22:47:06 -07:00
committed by GitHub
parent 4241ca523e
commit 685e0ccf7e
12 changed files with 177 additions and 28 deletions

View File

@@ -25,8 +25,7 @@ import { NotebookModel } from 'sql/workbench/services/notebook/browser/models/no
import { ISanitizer, defaultSanitizer } from 'sql/workbench/services/notebook/browser/outputs/sanitizer';
import { CellToggleMoreActions } from 'sql/workbench/contrib/notebook/browser/cellToggleMoreActions';
import { CodeComponent } from 'sql/workbench/contrib/notebook/browser/cellViews/code.component';
import { BaseTextEditor } from 'vs/workbench/browser/parts/editor/textEditor';
import { NotebookRange } from 'sql/workbench/services/notebook/browser/notebookService';
import { NotebookRange, ICellEditorProvider } from 'sql/workbench/services/notebook/browser/notebookService';
import { IColorTheme } from 'vs/platform/theme/common/themeService';
export const TEXT_SELECTOR: string = 'text-cell-component';
@@ -106,6 +105,14 @@ export class TextCellComponent extends CellView implements OnInit, OnChanges {
}));
}
public get cellEditors(): ICellEditorProvider[] {
let editors: ICellEditorProvider[] = [];
if (this.markdowncodeCell) {
editors.push(...this.markdowncodeCell.toArray());
}
return editors;
}
//Gets sanitizer from ISanitizer interface
private get sanitizer(): ISanitizer {
if (this._sanitizer) {
@@ -121,15 +128,6 @@ export class TextCellComponent extends CellView implements OnInit, OnChanges {
get activeCellId(): string {
return this._activeCellId;
}
/**
* Returns the code editor of makrdown cell in edit mode.
*/
getEditor(): BaseTextEditor | undefined {
if (this.markdowncodeCell.length > 0) {
return this.markdowncodeCell.first.getEditor();
}
return undefined;
}
private setLoading(isLoading: boolean): void {
this.cellModel.loaded = !isLoading;
@@ -231,6 +229,7 @@ export class TextCellComponent extends CellView implements OnInit, OnChanges {
public toggleEditMode(editMode?: boolean): void {
this.isEditMode = editMode !== undefined ? editMode : !this.isEditMode;
this.cellModel.isEditMode = this.isEditMode;
this.updateMoreActions();
this.updatePreview();
this._changeRef.detectChanges();