A model.

Hierarchy

Index

Events

onDidChangeContent

onDidChangeDecorations

  • onDidChangeDecorations(listener: function): IDisposable

onDidChangeLanguage

onDidChangeOptions

onWillDispose

  • An event emitted right before disposing the model.

    Parameters

    • listener: function
        • (): void
        • Returns void

    Returns IDisposable

Properties

id

id: string

A unique identifier associated with this model.

uri

uri: Uri

Gets the resource associated with this editor model.

Methods

applyEdits

  • applyEdits(operations: IIdentifiedSingleEditOperation[]): IIdentifiedSingleEditOperation[]
  • Edit the model without adding the edits to the undo stack. This can have dire consequences on the undo stack! See @pushEditOperations for the preferred way.

    Parameters

    • operations: IIdentifiedSingleEditOperation[]

      The edit operations.

    Returns IIdentifiedSingleEditOperation[]

    The inverse edit operations, that, when applied, will bring the model back to the previous state.

deltaDecorations

  • deltaDecorations(oldDecorations: string[], newDecorations: IModelDeltaDecoration[], ownerId?: number): string[]
  • Perform a minimum ammount 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.

    Parameters

    • oldDecorations: string[]

      Array containing previous decorations identifiers.

    • newDecorations: IModelDeltaDecoration[]

      Array describing what decorations should result after the call.

    • Optional ownerId: number

      Identifies the editor id in which these decorations should appear. If no ownerId is provided, the decorations will appear in all editors that attach this model.

    Returns string[]

    An array containing the new decorations identifiers.

detectIndentation

  • detectIndentation(defaultInsertSpaces: boolean, defaultTabSize: number): void

dispose

  • dispose(): void
  • Destroy this model. This will unbind the model from the mode and make all necessary clean-up to release this object to the GC.

    Returns void

findMatches

  • findMatches(searchString: string, searchOnlyEditableRange: boolean, isRegex: boolean, matchCase: boolean, wordSeparators: string, captureMatches: boolean, limitResultCount?: number): FindMatch[]
  • findMatches(searchString: string, searchScope: IRange, isRegex: boolean, matchCase: boolean, wordSeparators: string, captureMatches: boolean, limitResultCount?: number): FindMatch[]
  • Search the model.

    Parameters

    • searchString: string

      The string used to search. If it is a regular expression, set isRegex to true.

    • searchOnlyEditableRange: boolean

      Limit the searching to only search inside the editable range of the model.

    • isRegex: boolean

      Used to indicate that searchString is a regular expression.

    • matchCase: boolean

      Force the matching to match lower/upper case exactly.

    • wordSeparators: string

      Force the matching to match entire words only. Pass null otherwise.

    • captureMatches: boolean

      The result will contain the captured groups.

    • Optional limitResultCount: number

      Limit the number of results

    Returns FindMatch[]

    The ranges where the matches are. It is empty if not matches have been found.

  • Search the model.

    Parameters

    • searchString: string

      The string used to search. If it is a regular expression, set isRegex to true.

    • searchScope: IRange

      Limit the searching to only search inside this range.

    • isRegex: boolean

      Used to indicate that searchString is a regular expression.

    • matchCase: boolean

      Force the matching to match lower/upper case exactly.

    • wordSeparators: string

      Force the matching to match entire words only. Pass null otherwise.

    • captureMatches: boolean

      The result will contain the captured groups.

    • Optional limitResultCount: number

      Limit the number of results

    Returns FindMatch[]

    The ranges where the matches are. It is empty if no matches have been found.

findNextMatch

  • 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.

    Parameters

    • searchString: string

      The string used to search. If it is a regular expression, set isRegex to true.

    • searchStart: IPosition

      Start the searching at the specified position.

    • isRegex: boolean

      Used to indicate that searchString is a regular expression.

    • matchCase: boolean

      Force the matching to match lower/upper case exactly.

    • wordSeparators: string

      Force the matching to match entire words only. Pass null otherwise.

    • captureMatches: boolean

      The result will contain the captured groups.

    Returns FindMatch

    The range where the next match is. It is null if no next match has been found.

findPreviousMatch

  • 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.

    Parameters

    • searchString: string

      The string used to search. If it is a regular expression, set isRegex to true.

    • searchStart: IPosition

      Start the searching at the specified position.

    • isRegex: boolean

      Used to indicate that searchString is a regular expression.

    • matchCase: boolean

      Force the matching to match lower/upper case exactly.

    • wordSeparators: string

      Force the matching to match entire words only. Pass null otherwise.

    • captureMatches: boolean

      The result will contain the captured groups.

    Returns FindMatch

    The range where the previous match is. It is null if no previous match has been found.

getAllDecorations

  • getAllDecorations(ownerId?: number, filterOutValidation?: boolean): IModelDecoration[]
  • Gets all the decorations as an array.

    Parameters

    • Optional ownerId: number

      If set, it will ignore decorations belonging to other owners.

    • Optional filterOutValidation: boolean

      If set, it will ignore decorations specific to validation (i.e. warnings, errors).

    Returns IModelDecoration[]

getAlternativeVersionId

  • getAlternativeVersionId(): number

getDecorationOptions

getDecorationRange

  • getDecorationRange(id: string): Range

getDecorationsInRange

  • getDecorationsInRange(range: IRange, ownerId?: number, filterOutValidation?: boolean): IModelDecoration[]
  • Gets all the deocorations 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.

    Parameters

    • range: IRange

      The range to search in

    • Optional ownerId: number

      If set, it will ignore decorations belonging to other owners.

    • Optional filterOutValidation: boolean

      If set, it will ignore decorations specific to validation (i.e. warnings, errors).

    Returns IModelDecoration[]

    An array with the decorations

getEOL

  • getEOL(): string

getFullModelRange

  • getFullModelRange(): Range

getLineContent

  • getLineContent(lineNumber: number): string

getLineCount

  • getLineCount(): number

getLineDecorations

  • getLineDecorations(lineNumber: number, ownerId?: number, filterOutValidation?: boolean): IModelDecoration[]
  • Gets all the decorations for the line lineNumber as an array.

    Parameters

    • lineNumber: number

      The line number

    • Optional ownerId: number

      If set, it will ignore decorations belonging to other owners.

    • Optional filterOutValidation: boolean

      If set, it will ignore decorations specific to validation (i.e. warnings, errors).

    Returns IModelDecoration[]

    An array with the decorations

getLineFirstNonWhitespaceColumn

  • getLineFirstNonWhitespaceColumn(lineNumber: number): number

getLineLastNonWhitespaceColumn

  • getLineLastNonWhitespaceColumn(lineNumber: number): number

getLineMaxColumn

  • getLineMaxColumn(lineNumber: number): number

getLineMinColumn

  • getLineMinColumn(lineNumber: number): number

getLinesContent

  • getLinesContent(): string[]

getLinesDecorations

  • getLinesDecorations(startLineNumber: number, endLineNumber: number, ownerId?: number, filterOutValidation?: boolean): IModelDecoration[]
  • Gets all the decorations for the lines between startLineNumber and endLineNumber as an array.

    Parameters

    • startLineNumber: number

      The start line number

    • endLineNumber: number

      The end line number

    • Optional ownerId: number

      If set, it will ignore decorations belonging to other owners.

    • Optional filterOutValidation: boolean

      If set, it will ignore decorations specific to validation (i.e. warnings, errors).

    Returns IModelDecoration[]

    An array with the decorations

getModeId

  • getModeId(): string

getOffsetAt

getOneIndent

  • getOneIndent(): string

getOptions

getPositionAt

  • getPositionAt(offset: number): Position

getValue

  • getValue(eol?: EndOfLinePreference.TextDefined | EndOfLinePreference.LF | EndOfLinePreference.CRLF, preserveBOM?: boolean): string
  • Get the text stored in this model.

    Parameters

    • Optional eol: EndOfLinePreference.TextDefined | EndOfLinePreference.LF | EndOfLinePreference.CRLF

      The end of line character preference. Defaults to EndOfLinePreference.TextDefined.

    • Optional preserveBOM: boolean

    Returns string

    The text.

getValueInRange

  • getValueInRange(range: IRange, eol?: EndOfLinePreference.TextDefined | EndOfLinePreference.LF | EndOfLinePreference.CRLF): string
  • Get the text in a certain range.

    Parameters

    • range: IRange

      The range describing what text to get.

    • Optional eol: EndOfLinePreference.TextDefined | EndOfLinePreference.LF | EndOfLinePreference.CRLF

      The end of line character preference. This will only be used for multiline ranges. Defaults to EndOfLinePreference.TextDefined.

    Returns string

    The text.

getValueLength

  • getValueLength(eol?: EndOfLinePreference.TextDefined | EndOfLinePreference.LF | EndOfLinePreference.CRLF, preserveBOM?: boolean): number

getValueLengthInRange

  • getValueLengthInRange(range: IRange): number

getVersionId

  • getVersionId(): number

getWordAtPosition

getWordUntilPosition

isDisposed

  • isDisposed(): boolean

modifyPosition

  • Advances the given position by the given offest (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 ofsset is such that the new position would be in the middle of a multi-byte line terminator, throws an exception.

    Parameters

    Returns Position

normalizeIndentation

  • normalizeIndentation(str: string): string

pushEditOperations

  • 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.

    Parameters

    • beforeCursorState: Selection[]

      The cursor state before the edit operaions. This cursor state will be returned when undo or redo are invoked.

    • editOperations: IIdentifiedSingleEditOperation[]

      The edit operations.

    • cursorStateComputer: ICursorStateComputer

      A callback that can compute the resulting cursors state after the edit operations have been executed.

    Returns Selection[]

    The cursor state returned by the cursorStateComputer.

pushStackElement

  • pushStackElement(): void
  • Push a stack element onto the undo stack. This acts as an undo/redo point. The idea is to use pushEditOperations to edit the model and then to pushStackElement to create an undo/redo stop point.

    Returns void

setEOL

  • setEOL(eol: EndOfLineSequence.LF | EndOfLineSequence.CRLF): void

setValue

  • setValue(newValue: string): void

updateOptions

validatePosition

validateRange