save richTextCursorPosition/markdownCursorPosition (#17180)

* save richTextCursorPosition/markdownCursorPosition

* rename variables

* check to see if the nodes exist

* added comments

* add comments

* check if valid offset

* pr comments

* sqllint error fix
This commit is contained in:
Maddy
2021-10-06 23:24:22 -07:00
committed by GitHub
parent 56e961c972
commit f88bef8b4c
4 changed files with 97 additions and 2 deletions

View File

@@ -12,7 +12,7 @@ import { localize } from 'vs/nls';
import * as notebookUtils from 'sql/workbench/services/notebook/browser/models/notebookUtils';
import { CellTypes, CellType, NotebookChangeType, TextCellEditModes } from 'sql/workbench/services/notebook/common/contracts';
import { NotebookModel } from 'sql/workbench/services/notebook/browser/models/notebookModel';
import { ICellModel, IOutputChangedEvent, CellExecutionState, ICellModelOptions, ITableUpdatedEvent, CellEditModes } from 'sql/workbench/services/notebook/browser/models/modelInterfaces';
import { ICellModel, IOutputChangedEvent, CellExecutionState, ICellModelOptions, ITableUpdatedEvent, CellEditModes, ICaretPosition } from 'sql/workbench/services/notebook/browser/models/modelInterfaces';
import { IConnectionManagementService } from 'sql/platform/connection/common/connectionManagement';
import { IConnectionProfile } from 'sql/platform/connection/common/interfaces';
import { INotificationService, Severity } from 'vs/platform/notification/common/notification';
@@ -31,6 +31,7 @@ import { Disposable } from 'vs/base/common/lifecycle';
import * as TelemetryKeys from 'sql/platform/telemetry/common/telemetryKeys';
import { IAdsTelemetryService } from 'sql/platform/telemetry/common/telemetry';
import { IInsightOptions } from 'sql/workbench/common/editor/query/chartState';
import { IPosition } from 'vs/editor/common/core/position';
let modelId = 0;
const ads_execute_command = 'ads_execute_command';
@@ -85,6 +86,8 @@ export class CellModel extends Disposable implements ICellModel {
private _outputCounter = 0; // When re-executing the same cell, ensure that we apply chart options in the same order
private _attachments: nb.ICellAttachments | undefined;
private _preventNextChartCache: boolean = false;
public richTextCursorPosition: ICaretPosition | undefined;
public markdownCursorPosition: IPosition | undefined;
constructor(cellData: nb.ICellContents,
private _options: ICellModelOptions,

View File

@@ -23,6 +23,7 @@ import { IModelContentChangedEvent } from 'vs/editor/common/model/textModelEvent
import type { FutureInternal } from 'sql/workbench/services/notebook/browser/interfaces';
import { ICellValue, ResultSetSummary } from 'sql/workbench/services/query/common/query';
import { QueryResultId } from 'sql/workbench/services/notebook/browser/models/cell';
import { IPosition } from 'vs/editor/common/core/position';
export enum ViewMode {
Notebook,
@@ -548,6 +549,15 @@ export interface ICellModel {
* Returns the name of the attachment added to metadata.
*/
addAttachment(mimeType: string, base64Encoding: string, name: string): string;
richTextCursorPosition: ICaretPosition;
markdownCursorPosition: IPosition;
}
export interface ICaretPosition {
startElementNodes: number[];
startOffset: number;
endElementNodes: number[];
endOffset: number;
}
export interface IModelFactory {