Interface ITextModel
Expand description
interface ITextModel {
id: string;
onDidChangeAttached: IEvent<void>;
onDidChangeDecorations: IEvent<
IModelDecorationsChangedEvent,
>;
onDidChangeLanguage: IEvent<IModelLanguageChangedEvent>;
onDidChangeLanguageConfiguration: IEvent<
IModelLanguageConfigurationChangedEvent,
>;
onDidChangeOptions: IEvent<IModelOptionsChangedEvent>;
onWillDispose: IEvent<void>;
uri: Uri;
applyEdits(
operations: readonly IIdentifiedSingleEditOperation[],
): void;
applyEdits(
operations: readonly IIdentifiedSingleEditOperation[],
computeUndoEdits: false,
): void;
applyEdits(
operations: readonly IIdentifiedSingleEditOperation[],
computeUndoEdits: true,
): IValidEditOperation[];
canRedo(): boolean;
canUndo(): boolean;
createSnapshot(preserveBOM?: boolean): ITextSnapshot;
deltaDecorations(
oldDecorations: string[],
newDecorations: IModelDeltaDecoration[],
ownerId?: number,
): string[];
detectIndentation(
defaultInsertSpaces: boolean,
defaultTabSize: number,
): void;
dispose(): void;
findMatches(
searchString: string,
searchOnlyEditableRange: boolean,
isRegex: boolean,
matchCase: boolean,
wordSeparators: string,
captureMatches: boolean,
limitResultCount?: number,
): FindMatch[];
findMatches(
searchString: string,
searchScope: IRange | IRange[],
isRegex: boolean,
matchCase: boolean,
wordSeparators: string,
captureMatches: boolean,
limitResultCount?: number,
): FindMatch[];
findNextMatch(
searchString: string,
searchStart: IPosition,
isRegex: boolean,
matchCase: boolean,
wordSeparators: string,
captureMatches: boolean,
): FindMatch;
findPreviousMatch(
searchString: string,
searchStart: IPosition,
isRegex: boolean,
matchCase: boolean,
wordSeparators: string,
captureMatches: boolean,
): FindMatch;
getAllDecorations(
ownerId?: number,
filterOutValidation?: boolean,
filterFontDecorations?: boolean,
): IModelDecoration[];
getAllMarginDecorations(
ownerId?: number,
): IModelDecoration[];
getAlternativeVersionId(): number;
getCharacterCountInRange(
range: IRange,
eol?: EndOfLinePreference,
): number;
getCustomLineHeightsDecorations(
ownerId?: number,
): IModelDecoration[];
getDecorationOptions(
id: string,
): IModelDecorationOptions;
getDecorationRange(id: string): Range;
getDecorationsInRange(
range: IRange,
ownerId?: number,
filterOutValidation?: boolean,
filterFontDecorations?: boolean,
onlyMinimapDecorations?: boolean,
onlyMarginDecorations?: boolean,
): IModelDecoration[];
getEndOfLineSequence(): EndOfLineSequence;
getEOL(): string;
getFullModelRange(): Range;
getInjectedTextDecorations(
ownerId?: number,
): IModelDecoration[];
getLanguageId(): string;
getLineContent(lineNumber: number): string;
getLineCount(): number;
getLineDecorations(
lineNumber: number,
ownerId?: number,
filterOutValidation?: boolean,
filterFontDecorations?: boolean,
): IModelDecoration[];
getLineFirstNonWhitespaceColumn(
lineNumber: number,
): number;
getLineLastNonWhitespaceColumn(
lineNumber: number,
): number;
getLineLength(lineNumber: number): number;
getLineMaxColumn(lineNumber: number): number;
getLineMinColumn(lineNumber: number): number;
getLinesContent(): string[];
getLinesDecorations(
startLineNumber: number,
endLineNumber: number,
ownerId?: number,
filterOutValidation?: boolean,
filterFontDecorations?: boolean,
): IModelDecoration[];
getOffsetAt(position: IPosition): number;
getOptions(): TextModelResolvedOptions;
getOverviewRulerDecorations(
ownerId?: number,
filterOutValidation?: boolean,
filterFontDecorations?: boolean,
): IModelDecoration[];
getPositionAt(offset: number): Position;
getValue(
eol?: EndOfLinePreference,
preserveBOM?: boolean,
): string;
getValueInRange(
range: IRange,
eol?: EndOfLinePreference,
): string;
getValueLength(
eol?: EndOfLinePreference,
preserveBOM?: boolean,
): number;
getValueLengthInRange(
range: IRange,
eol?: EndOfLinePreference,
): number;
getVersionId(): number;
getWordAtPosition(position: IPosition): IWordAtPosition;
getWordUntilPosition(
position: IPosition,
): IWordAtPosition;
isAttachedToEditor(): boolean;
isDisposed(): boolean;
isValidRange(range: IRange): boolean;
modifyPosition(
position: IPosition,
offset: number,
): Position;
normalizeIndentation(str: string): string;
onDidChangeContent(
listener: (e: IModelContentChangedEvent) => void,
): IDisposable;
popStackElement(): void;
pushEditOperations(
beforeCursorState: Selection[],
editOperations: IIdentifiedSingleEditOperation[],
cursorStateComputer: ICursorStateComputer,
): Selection[];
pushEOL(eol: EndOfLineSequence): void;
pushStackElement(): void;
redo(): void | Promise<void>;
setEOL(eol: EndOfLineSequence): void;
setValue(newValue: string | ITextSnapshot): void;
undo(): void | Promise<void>;
updateOptions(newOpts: ITextModelUpdateOptions): void;
validatePosition(position: IPosition): Position;
validateRange(range: IRange): Range;
}Properties§
readonly id: stringA unique identifier associated with this model.
readonly uri: UriGets the resource associated with this editor model.
Methods§
§applyEdits(
operations: readonly IIdentifiedSingleEditOperation[],
): void
applyEdits(
operations: readonly IIdentifiedSingleEditOperation[],
): void
Edit the model without adding the edits to the undo stack. This can have dire consequences on the undo stack! See
§applyEdits(
operations: readonly IIdentifiedSingleEditOperation[],
computeUndoEdits: false,
): void
applyEdits(
operations: readonly IIdentifiedSingleEditOperation[],
computeUndoEdits: false,
): void
§applyEdits(
operations: readonly IIdentifiedSingleEditOperation[],
computeUndoEdits: true,
): IValidEditOperation[]
applyEdits(
operations: readonly IIdentifiedSingleEditOperation[],
computeUndoEdits: true,
): IValidEditOperation[]
§canRedo(): boolean
canRedo(): boolean
Is there anything in the redo stack?
§canUndo(): boolean
canUndo(): boolean
Is there anything in the undo stack?
§createSnapshot(preserveBOM?: boolean): ITextSnapshot
createSnapshot(preserveBOM?: boolean): ITextSnapshot
Get the text stored in this model.
§deltaDecorations(
oldDecorations: string[],
newDecorations: IModelDeltaDecoration[],
ownerId?: number,
): string[]
deltaDecorations(
oldDecorations: string[],
newDecorations: IModelDeltaDecoration[],
ownerId?: number,
): string[]
Perform a minimum amount of operations, in order to transform the decorations
identified by oldDecorations to the decorations described by newDecorations
and returns the new identifiers associated with the resulting decorations.
§detectIndentation(
defaultInsertSpaces: boolean,
defaultTabSize: number,
): void
detectIndentation(
defaultInsertSpaces: boolean,
defaultTabSize: number,
): void
Detect the indentation options for this model from its content.
§dispose(): void
dispose(): void
Destroy this model.
§findMatches(
searchString: string,
searchOnlyEditableRange: boolean,
isRegex: boolean,
matchCase: boolean,
wordSeparators: string,
captureMatches: boolean,
limitResultCount?: number,
): FindMatch[]
findMatches(
searchString: string,
searchOnlyEditableRange: boolean,
isRegex: boolean,
matchCase: boolean,
wordSeparators: string,
captureMatches: boolean,
limitResultCount?: number,
): FindMatch[]
Search the model.
§findMatches(
searchString: string,
searchScope: IRange | IRange[],
isRegex: boolean,
matchCase: boolean,
wordSeparators: string,
captureMatches: boolean,
limitResultCount?: number,
): FindMatch[]
findMatches(
searchString: string,
searchScope: IRange | IRange[],
isRegex: boolean,
matchCase: boolean,
wordSeparators: string,
captureMatches: boolean,
limitResultCount?: number,
): FindMatch[]
Search the model.
§findNextMatch(
searchString: string,
searchStart: IPosition,
isRegex: boolean,
matchCase: boolean,
wordSeparators: string,
captureMatches: boolean,
): FindMatch
findNextMatch(
searchString: string,
searchStart: IPosition,
isRegex: boolean,
matchCase: boolean,
wordSeparators: string,
captureMatches: boolean,
): FindMatch
Search the model for the next match. Loops to the beginning of the model if needed.
§findPreviousMatch(
searchString: string,
searchStart: IPosition,
isRegex: boolean,
matchCase: boolean,
wordSeparators: string,
captureMatches: boolean,
): FindMatch
findPreviousMatch(
searchString: string,
searchStart: IPosition,
isRegex: boolean,
matchCase: boolean,
wordSeparators: string,
captureMatches: boolean,
): FindMatch
Search the model for the previous match. Loops to the end of the model if needed.
§getAllDecorations(
ownerId?: number,
filterOutValidation?: boolean,
filterFontDecorations?: boolean,
): IModelDecoration[]
getAllDecorations(
ownerId?: number,
filterOutValidation?: boolean,
filterFontDecorations?: boolean,
): IModelDecoration[]
Gets all the decorations as an array.
§getAllMarginDecorations(
ownerId?: number,
): IModelDecoration[]
getAllMarginDecorations(
ownerId?: number,
): IModelDecoration[]
Gets all decorations that render in the glyph margin as an array.
§getAlternativeVersionId(): number
getAlternativeVersionId(): number
Get the alternative version id of the model. This alternative version id is not always incremented, it will return the same values in the case of undo-redo.
§getCharacterCountInRange(
range: IRange,
eol?: EndOfLinePreference,
): number
getCharacterCountInRange(
range: IRange,
eol?: EndOfLinePreference,
): number
Get the character count of text in a certain range.
§getCustomLineHeightsDecorations(
ownerId?: number,
): IModelDecoration[]
getCustomLineHeightsDecorations(
ownerId?: number,
): IModelDecoration[]
Gets all the decorations that contain custom line heights.
§getDecorationOptions(id: string): IModelDecorationOptions
getDecorationOptions(id: string): IModelDecorationOptions
Get the options associated with a decoration.
§getDecorationsInRange(
range: IRange,
ownerId?: number,
filterOutValidation?: boolean,
filterFontDecorations?: boolean,
onlyMinimapDecorations?: boolean,
onlyMarginDecorations?: boolean,
): IModelDecoration[]
getDecorationsInRange(
range: IRange,
ownerId?: number,
filterOutValidation?: boolean,
filterFontDecorations?: boolean,
onlyMinimapDecorations?: boolean,
onlyMarginDecorations?: boolean,
): IModelDecoration[]
Gets all the decorations in a range as an array. Only startLineNumber and endLineNumber from range are used for filtering.
So for now it returns all the decorations on the same line as range.
§getEndOfLineSequence(): EndOfLineSequence
getEndOfLineSequence(): EndOfLineSequence
Get the end of line sequence predominantly used in the text buffer.
§getEOL(): string
getEOL(): string
Get the end of line sequence predominantly used in the text buffer.
§getInjectedTextDecorations(
ownerId?: number,
): IModelDecoration[]
getInjectedTextDecorations(
ownerId?: number,
): IModelDecoration[]
Gets all the decorations that contain injected text.
§getLanguageId(): string
getLanguageId(): string
Get the language associated with this model.
§getLineContent(lineNumber: number): string
getLineContent(lineNumber: number): string
Get the text for a certain line.
§getLineCount(): number
getLineCount(): number
Get the number of lines in the model.
§getLineDecorations(
lineNumber: number,
ownerId?: number,
filterOutValidation?: boolean,
filterFontDecorations?: boolean,
): IModelDecoration[]
getLineDecorations(
lineNumber: number,
ownerId?: number,
filterOutValidation?: boolean,
filterFontDecorations?: boolean,
): IModelDecoration[]
Gets all the decorations for the line lineNumber as an array.
§getLineFirstNonWhitespaceColumn(lineNumber: number): number
getLineFirstNonWhitespaceColumn(lineNumber: number): number
Returns the column before the first non whitespace character for line at lineNumber.
Returns 0 if line is empty or contains only whitespace.
§getLineLastNonWhitespaceColumn(lineNumber: number): number
getLineLastNonWhitespaceColumn(lineNumber: number): number
Returns the column after the last non whitespace character for line at lineNumber.
Returns 0 if line is empty or contains only whitespace.
§getLineLength(lineNumber: number): number
getLineLength(lineNumber: number): number
Get the text length for a certain line.
§getLineMaxColumn(lineNumber: number): number
getLineMaxColumn(lineNumber: number): number
Get the maximum legal column for line at lineNumber
§getLineMinColumn(lineNumber: number): number
getLineMinColumn(lineNumber: number): number
Get the minimum legal column for line at lineNumber
§getLinesContent(): string[]
getLinesContent(): string[]
Get the text for all lines.
§getLinesDecorations(
startLineNumber: number,
endLineNumber: number,
ownerId?: number,
filterOutValidation?: boolean,
filterFontDecorations?: boolean,
): IModelDecoration[]
getLinesDecorations(
startLineNumber: number,
endLineNumber: number,
ownerId?: number,
filterOutValidation?: boolean,
filterFontDecorations?: boolean,
): IModelDecoration[]
Gets all the decorations for the lines between startLineNumber and endLineNumber as an array.
§getOffsetAt(position: IPosition): number
getOffsetAt(position: IPosition): number
Converts the position to a zero-based offset.
The position will be adjusted.
§getOptions(): TextModelResolvedOptions
getOptions(): TextModelResolvedOptions
Get the resolved options for this model.
§getOverviewRulerDecorations(
ownerId?: number,
filterOutValidation?: boolean,
filterFontDecorations?: boolean,
): IModelDecoration[]
getOverviewRulerDecorations(
ownerId?: number,
filterOutValidation?: boolean,
filterFontDecorations?: boolean,
): IModelDecoration[]
Gets all the decorations that should be rendered in the overview ruler as an array.
§getValue(
eol?: EndOfLinePreference,
preserveBOM?: boolean,
): string
getValue(
eol?: EndOfLinePreference,
preserveBOM?: boolean,
): string
Get the text stored in this model.
§getValueInRange(
range: IRange,
eol?: EndOfLinePreference,
): string
getValueInRange(
range: IRange,
eol?: EndOfLinePreference,
): string
Get the text in a certain range.
§getValueLength(
eol?: EndOfLinePreference,
preserveBOM?: boolean,
): number
getValueLength(
eol?: EndOfLinePreference,
preserveBOM?: boolean,
): number
Get the length of the text stored in this model.
§getValueLengthInRange(
range: IRange,
eol?: EndOfLinePreference,
): number
getValueLengthInRange(
range: IRange,
eol?: EndOfLinePreference,
): number
Get the length of text in a certain range.
§getVersionId(): number
getVersionId(): number
Get the current version id of the model. Anytime a change happens to the model (even undo/redo), the version id is incremented.
§getWordAtPosition(position: IPosition): IWordAtPosition
getWordAtPosition(position: IPosition): IWordAtPosition
Get the word under or besides position.
§getWordUntilPosition(position: IPosition): IWordAtPosition
getWordUntilPosition(position: IPosition): IWordAtPosition
Get the word under or besides position trimmed to position.column
§isAttachedToEditor(): boolean
isAttachedToEditor(): boolean
Returns if this model is attached to an editor or not.
§isDisposed(): boolean
isDisposed(): boolean
Returns if the model was disposed or not.
§modifyPosition(
position: IPosition,
offset: number,
): Position
modifyPosition(
position: IPosition,
offset: number,
): Position
Advances the given position by the given offset (negative offsets are also accepted) and returns it as a new valid position.
If the offset and position are such that their combination goes beyond the beginning or end of the model, throws an exception.
If the offset is such that the new position would be in the middle of a multi-byte line terminator, throws an exception.
§normalizeIndentation(str: string): string
normalizeIndentation(str: string): string
Normalize a string containing whitespace according to indentation rules (converts to spaces or to tabs).
§popStackElement(): void
popStackElement(): void
Open the current undo-redo element. This offers a way to remove the current undo/redo stop point.
§pushEditOperations(
beforeCursorState: Selection[],
editOperations: IIdentifiedSingleEditOperation[],
cursorStateComputer: ICursorStateComputer,
): Selection[]
pushEditOperations(
beforeCursorState: Selection[],
editOperations: IIdentifiedSingleEditOperation[],
cursorStateComputer: ICursorStateComputer,
): Selection[]
Push edit operations, basically editing the model. This is the preferred way of editing the model. The edit operations will land on the undo stack.
§pushEOL(eol: EndOfLineSequence): void
pushEOL(eol: EndOfLineSequence): void
Change the end of line sequence. This is the preferred way of changing the eol sequence. This will land on the undo stack.
§pushStackElement(): void
pushStackElement(): void
Close the current undo-redo element. This offers a way to create an undo/redo stop point.
§redo(): void | Promise<void>
redo(): void | Promise<void>
Redo edit operations until the next undo/redo point. The inverse edit operations will be pushed on the undo stack.
§setEOL(eol: EndOfLineSequence): void
setEOL(eol: EndOfLineSequence): void
Change the end of line sequence without recording in the undo stack. This can have dire consequences on the undo stack! See
§setValue(newValue: string | ITextSnapshot): void
setValue(newValue: string | ITextSnapshot): void
Replace the entire text buffer value contained in this model.
§undo(): void | Promise<void>
undo(): void | Promise<void>
Undo edit operations until the previous undo/redo point. The inverse edit operations will be pushed on the redo stack.
§updateOptions(newOpts: ITextModelUpdateOptions): void
updateOptions(newOpts: ITextModelUpdateOptions): void
Change the options of this model.
Events§
readonly on Did Change Attached: IEvent<void>An event emitted when the model has been attached to the first editor or detached from the last editor.
readonly on Did Change Decorations: IEvent<IModelDecorationsChangedEvent>An event emitted when decorations of the model have changed.
readonly on Did Change Language: IEvent<IModelLanguageChangedEvent>An event emitted when the language associated with the model has changed.
readonly on Did Change Language Configuration: IEvent<IModelLanguageConfigurationChangedEvent>An event emitted when the language configuration associated with the model has changed.
readonly on Did Change Options: IEvent<IModelOptionsChangedEvent>An event emitted when the model options have changed.
readonly on Will Dispose: IEvent<void>An event emitted right before disposing the model.
§onDidChangeContent(
listener: (e: IModelContentChangedEvent) => void,
): IDisposable
onDidChangeContent(
listener: (e: IModelContentChangedEvent) => void,
): IDisposable
An event emitted when the contents of the model have changed.
A model.