Theia API Documentation v1.65.0
    Preparing search index...
    interface TextEditorDocument {
        autosaveable?: boolean;
        dirty: boolean;
        languageId: string;
        lineCount: number;
        onContentChanged: Event<void>;
        onDirtyChanged: Event<void>;
        uri: string;
        version: number;
        applySnapshot?(snapshot: object): void;
        createSnapshot?(): Saveable.Snapshot;
        dispose(): void;
        filters?(): { [name: string]: string[] };
        findMatches?(options: FindMatchesOptions): FindMatch[];
        getLineContent(lineNumber: number): string;
        getLineMaxColumn(lineNumber: number): number;
        getText(range?: Range): string;
        offsetAt(position: Position): number;
        positionAt(offset: number): Position;
        revert?(options?: RevertOptions): Promise<void>;
        save(options?: SaveOptions): MaybePromise<void>;
        saveAs?(options: SaveAsOptions): MaybePromise<void>;
        serialize?(): Promise<BinaryBuffer>;
        toValidPosition(position: Position): Position;
        toValidRange(range: Range): Range;
    }

    Hierarchy (View Summary)

    Implemented by

    Index

    Properties

    autosaveable?: boolean

    If false, the saveable will not participate in autosaving.

    dirty: boolean
    languageId: string

    The identifier of the language associated with this document.

    lineCount: number

    The number of lines in this document.

    onContentChanged: Event<void>

    This event is fired when the content of the saveable changes. While onDirtyChanged is fired to notify the UI that the widget is dirty, onContentChanged is used for the auto save throttling.

    onDirtyChanged: Event<void>

    This event is fired when the content of the dirty variable changes.

    uri: string

    The associated URI for this document. Most documents have the file-scheme, indicating that they represent files on disk. However, some documents may have other schemes indicating that they are not available on disk.

    version: number

    The version number of this document (it will increase after each change, including undo/redo).

    Methods

    • Applies the given snapshot to the dirty state.

      Parameters

      • snapshot: object

      Returns void

    • Dispose this object.

      Returns void

    • Optionally return file filters for the "Save As" dialog. The keys of the returned object are the names of the filters and the values are arrays of file extensions. For example: { 'Text Files': ['txt', 'text'], 'All Files': ['*'] } If no filters are provided, a default filter of All Files (*.*) will be used.

      Returns { [name: string]: string[] }

    • Get the text of this document. A substring can be retrieved by providing a range.

      Parameters

      • Optionalrange: Range

        (optional) An range within the document to return. If no range is passed, the full content is returned. Invalid range positions are adjusted as described in Position.line and Position.character. If the start range position is greater than the end range position, then the effect of getText is as if the two positions were swapped.

      Returns string

      The text of this document or a substring of the text if a range is provided.

    • Converts the position to a zero-based offset. Invalid positions are adjusted as described in Position.line and Position.character.

      Parameters

      Returns number

      A valid zero-based offset.

    • Converts a zero-based offset to a position.

      Parameters

      • offset: number

        A zero-based offset.

      Returns Position

      A valid position.

    • Reverts dirty changes.

      Parameters

      Returns Promise<void>

    • Serializes the full state of the saveable item to a binary buffer.

      Returns Promise<BinaryBuffer>

    • Creates a valid position. If the position is outside of the backing document, this method will return a position that is ensured to be inside the document and valid. For example, when the position is { line: 1, character: 0 } and the document is empty, this method will return with { line: 0, character: 0 }.

      Parameters

      Returns Position

    • Creates a valid range. If the range argument is outside of the document, this method will return with a new range that does not exceed the boundaries of the document. For example, if the argument is { start: { line: 1, character: 0 }, end: { line: 1, character: 0 } } and the document is empty, the return value is { start: { line: 0, character: 0 }, end: { line: 0, character: 0 } }.

      Parameters

      Returns Range