Theia API Documentation v1.65.0
    Preparing search index...

    Represents a text editor. To close editor use 'workbench.action.closeActiveEditor' command.

    interface TextEditor {
        diffInformation: undefined | TextEditorDiffInformation[];
        document: TextDocument;
        options: TextEditorOptions;
        selection: Selection;
        selections: readonly Selection[];
        viewColumn: undefined | ViewColumn;
        visibleRanges: readonly Range[];
        edit(
            callback: (editBuilder: TextEditorEdit) => void,
            options?: { undoStopAfter: boolean; undoStopBefore: boolean },
        ): Thenable<boolean>;
        hide(): void;
        insertSnippet(
            snippet: SnippetString,
            location?: Position | Range | Position[] | Range[],
            options?: {
                keepWhitespace?: boolean;
                undoStopAfter: boolean;
                undoStopBefore: boolean;
            },
        ): Thenable<boolean>;
        revealRange(range: Range, revealType?: TextEditorRevealType): void;
        setDecorations(
            decorationType: TextEditorDecorationType,
            rangesOrOptions: Range[] | DecorationOptions[],
        ): void;
        show(column?: ViewColumn): void;
    }

    Implemented by

    Index

    Properties

    diffInformation: undefined | TextEditorDiffInformation[]
    document: TextDocument

    The document associated with this text editor. The document will be the same for the entire lifetime of this text editor.

    Text editor options.

    selection: Selection

    The primary selection on this text editor. Shorthand for TextEditor.selections[0].

    selections: readonly Selection[]

    The selections in this text editor. The primary selection is always at index 0.

    viewColumn: undefined | ViewColumn

    The column in which this editor shows. Will be undefined in case this isn't one of the main editors, e.g. an embedded editor, or when the editor column is larger than three.

    visibleRanges: readonly Range[]

    The current visible ranges in the editor (vertically). This accounts only for vertical scrolling, and not for horizontal scrolling.

    Methods

    • Perform an edit on the document associated with this text editor.

      The given callback-function is invoked with an edit-builder which must be used to make edits. Note that the edit-builder is only valid while the callback executes.

      Parameters

      • callback: (editBuilder: TextEditorEdit) => void

        A function which can create edits using an edit-builder.

      • Optionaloptions: { undoStopAfter: boolean; undoStopBefore: boolean }

        The undo/redo behavior around this edit. By default, undo stops will be created before and after this edit.

      Returns Thenable<boolean>

      A promise that resolves with a value indicating if the edits could be applied.

    • Insert a snippet and put the editor into snippet mode. "Snippet mode" means the editor adds placeholders and additional cursors so that the user can complete or accept the snippet.

      Parameters

      • snippet: SnippetString

        The snippet to insert in this edit.

      • Optionallocation: Position | Range | Position[] | Range[]

        Position or range at which to insert the snippet, defaults to the current editor selection or selections.

      • Optionaloptions: { keepWhitespace?: boolean; undoStopAfter: boolean; undoStopBefore: boolean }

        The undo/redo behavior around this edit. By default, undo stops will be created before and after this edit.

        • Optional ReadonlykeepWhitespace?: boolean

          Keep whitespace of the SnippetString.value as is.

        • ReadonlyundoStopAfter: boolean

          Add undo stop after making the edits.

        • ReadonlyundoStopBefore: boolean

          Add undo stop before making the edits.

      Returns Thenable<boolean>

      A promise that resolves with a value indicating if the snippet could be inserted. Note that the promise does not signal that the snippet is completely filled-in or accepted.