diff --git a/src/vs/editor/common/model/editableTextModel.ts b/src/vs/editor/common/model/editableTextModel.ts index 2df8c63382883..44bcf28c268df 100644 --- a/src/vs/editor/common/model/editableTextModel.ts +++ b/src/vs/editor/common/model/editableTextModel.ts @@ -7,7 +7,7 @@ import { Range, IRange } from 'vs/editor/common/core/range'; import * as editorCommon from 'vs/editor/common/editorCommon'; import { EditStack } from 'vs/editor/common/model/editStack'; -import { ILineEdit, LineMarker, ModelLine, MarkersTracker } from 'vs/editor/common/model/modelLine'; +import { ILineEdit, LineMarker, ModelLine, MarkersTracker, IModelLine } from 'vs/editor/common/model/modelLine'; import { TextModelWithDecorations, ModelDecorationOptions } from 'vs/editor/common/model/textModelWithDecorations'; import * as strings from 'vs/base/common/strings'; import * as arrays from 'vs/base/common/arrays'; @@ -649,7 +649,7 @@ export class EditableTextModel extends TextModelWithDecorations implements edito this._invalidateLine(spliceLineNumber - 1); // Lines in the middle - let newLines: ModelLine[] = []; + let newLines: IModelLine[] = []; let newLinesContent: string[] = []; let newLinesLengths = new Uint32Array(insertingLinesCnt - editingLinesCnt); for (let j = editingLinesCnt + 1; j <= insertingLinesCnt; j++) { diff --git a/src/vs/editor/common/model/modelLine.ts b/src/vs/editor/common/model/modelLine.ts index 50fd78c893098..dfe85c80b254a 100644 --- a/src/vs/editor/common/model/modelLine.ts +++ b/src/vs/editor/common/model/modelLine.ts @@ -158,7 +158,36 @@ function computePlusOneIndentLevel(line: string, tabSize: number): number { return indent + 1; } -export class ModelLine { +export interface IModelLine { + readonly text: string; + isInvalid: boolean; + + // --- markers + addMarker(marker: LineMarker): void; + addMarkers(markers: LineMarker[]): void; + removeMarker(marker: LineMarker): void; + removeMarkers(deleteMarkers: { [markerId: string]: boolean; }): void; + getMarkers(): LineMarker[]; + + // --- tokenization + resetTokenizationState(): void; + getState(): IState; + setState(state: IState): void; + getTokens(topLevelLanguageId: LanguageId): LineTokens; + setTokens(topLevelLanguageId: LanguageId, tokens: Uint32Array): void; + + // --- indentation + updateTabSize(tabSize: number): void; + getIndentLevel(): number; + + // --- editing + updateLineNumber(markersTracker: MarkersTracker, newLineNumber: number): void; + applyEdits(markersTracker: MarkersTracker, edits: ILineEdit[], tabSize: number): number; + append(markersTracker: MarkersTracker, myLineNumber: number, other: ModelLine, tabSize: number): void; + split(markersTracker: MarkersTracker, splitColumn: number, forceMoveMarkers: boolean, tabSize: number): ModelLine; +} + +export class ModelLine implements IModelLine { private _text: string; public get text(): string { return this._text; } diff --git a/src/vs/editor/common/model/textModel.ts b/src/vs/editor/common/model/textModel.ts index 45b786fc2f959..2958d203e26e2 100644 --- a/src/vs/editor/common/model/textModel.ts +++ b/src/vs/editor/common/model/textModel.ts @@ -9,7 +9,7 @@ import * as strings from 'vs/base/common/strings'; import { Position, IPosition } from 'vs/editor/common/core/position'; import { Range, IRange } from 'vs/editor/common/core/range'; import * as editorCommon from 'vs/editor/common/editorCommon'; -import { ModelLine } from 'vs/editor/common/model/modelLine'; +import { ModelLine, IModelLine } from 'vs/editor/common/model/modelLine'; import { guessIndentation } from 'vs/editor/common/model/indentationGuesser'; import { EDITOR_MODEL_DEFAULTS } from 'vs/editor/common/config/editorOptions'; import { PrefixSumComputer } from 'vs/editor/common/viewModel/prefixSumComputer'; @@ -76,7 +76,7 @@ export class TextModel implements editorCommon.ITextModel { protected readonly _eventEmitter: OrderGuaranteeEventEmitter; - /*protected*/ _lines: ModelLine[]; + /*protected*/ _lines: IModelLine[]; protected _EOL: string; protected _isDisposed: boolean; protected _isDisposing: boolean; @@ -756,7 +756,7 @@ export class TextModel implements editorCommon.ITextModel { private _constructLines(textSource: ITextSource): void { const tabSize = this._options.tabSize; let rawLines = textSource.lines; - let modelLines: ModelLine[] = []; + let modelLines: IModelLine[] = []; for (let i = 0, len = rawLines.length; i < len; i++) { modelLines[i] = new ModelLine(rawLines[i], tabSize);