Interface IDiffEditor

Expand description

A rich diff editor.

interface IDiffEditor {
    onDidChangeModel: IEvent<void>;
    onDidUpdateDiff: IEvent<void>;
    accessibleDiffViewerNext(): void;
    accessibleDiffViewerPrev(): void;
    createDecorationsCollection(
        decorations?: IModelDeltaDecoration[],
    ): IEditorDecorationsCollection;
    createViewModel(
        model: IDiffEditorModel,
    ): IDiffEditorViewModel;
    dispose(): void;
    focus(): void;
    getContainerDomNode(): HTMLElement;
    getEditorType(): string;
    getId(): string;
    getLineChanges(): ILineChange[];
    getModel(): IDiffEditorModel;
    getModifiedEditor(): ICodeEditor;
    getOriginalEditor(): ICodeEditor;
    getPosition(): Position;
    getSelection(): Selection;
    getSelections(): Selection[];
    getSupportedActions(): IEditorAction[];
    getVisibleColumnFromPosition(
        position: IPosition,
    ): number;
    goToDiff(target: "next" | "previous"): void;
    handleInitialized(): void;
    hasTextFocus(): boolean;
    layout(
        dimension?: IDimension,
        postponeRendering?: boolean,
    ): void;
    onDidDispose(listener: () => void): IDisposable;
    restoreViewState(state: IDiffEditorViewState): void;
    revealFirstDiff(): unknown;
    revealLine(
        lineNumber: number,
        scrollType?: ScrollType,
    ): void;
    revealLineInCenter(
        lineNumber: number,
        scrollType?: ScrollType,
    ): void;
    revealLineInCenterIfOutsideViewport(
        lineNumber: number,
        scrollType?: ScrollType,
    ): void;
    revealLineNearTop(
        lineNumber: number,
        scrollType?: ScrollType,
    ): void;
    revealLines(
        startLineNumber: number,
        endLineNumber: number,
        scrollType?: ScrollType,
    ): void;
    revealLinesInCenter(
        lineNumber: number,
        endLineNumber: number,
        scrollType?: ScrollType,
    ): void;
    revealLinesInCenterIfOutsideViewport(
        lineNumber: number,
        endLineNumber: number,
        scrollType?: ScrollType,
    ): void;
    revealLinesNearTop(
        lineNumber: number,
        endLineNumber: number,
        scrollType?: ScrollType,
    ): void;
    revealPosition(
        position: IPosition,
        scrollType?: ScrollType,
    ): void;
    revealPositionInCenter(
        position: IPosition,
        scrollType?: ScrollType,
    ): void;
    revealPositionInCenterIfOutsideViewport(
        position: IPosition,
        scrollType?: ScrollType,
    ): void;
    revealPositionNearTop(
        position: IPosition,
        scrollType?: ScrollType,
    ): void;
    revealRange(
        range: IRange,
        scrollType?: ScrollType,
    ): void;
    revealRangeAtTop(
        range: IRange,
        scrollType?: ScrollType,
    ): void;
    revealRangeInCenter(
        range: IRange,
        scrollType?: ScrollType,
    ): void;
    revealRangeInCenterIfOutsideViewport(
        range: IRange,
        scrollType?: ScrollType,
    ): void;
    revealRangeNearTop(
        range: IRange,
        scrollType?: ScrollType,
    ): void;
    revealRangeNearTopIfOutsideViewport(
        range: IRange,
        scrollType?: ScrollType,
    ): void;
    saveViewState(): IDiffEditorViewState;
    setModel(
        model: IDiffEditorModel | IDiffEditorViewModel,
    ): void;
    setPosition(position: IPosition, source?: string): void;
    setSelection(selection: IRange, source?: string): void;
    setSelection(selection: Range, source?: string): void;
    setSelection(
        selection: ISelection,
        source?: string,
    ): void;
    setSelection(
        selection: Selection,
        source?: string,
    ): void;
    setSelections(
        selections: readonly ISelection[],
        source?: string,
    ): void;
    trigger(
        source: string,
        handlerId: string,
        payload: unknown,
    ): void;
    updateOptions(newOptions: IDiffEditorOptions): void;
}

Methods§

§

accessibleDiffViewerNext(): void

§

accessibleDiffViewerPrev(): void

§

createDecorationsCollection(
    decorations?: IModelDeltaDecoration[],
): IEditorDecorationsCollection

Create a collection of decorations. All decorations added through this collection will get the ownerId of the editor (meaning they will not show up in other editors). These decorations will be automatically cleared when the editor's model changes.

§

createViewModel(
    model: IDiffEditorModel,
): IDiffEditorViewModel

§

dispose(): void

Dispose the editor.

§

focus(): void

Brings browser focus to the editor text

§

getContainerDomNode(): HTMLElement

§

getEditorType(): string

Get the editor type. Please see EditorType. This is to avoid an instanceof check

§

getId(): string

Get a unique id for this editor instance.

§

getLineChanges(): ILineChange[]

Get the computed diff information.

§

getModel(): IDiffEditorModel

Type the getModel() of IEditor.

§

getModifiedEditor(): ICodeEditor

Get the modified editor.

§

getOriginalEditor(): ICodeEditor

Get the original editor.

§

getPosition(): Position

Returns the primary position of the cursor.

§

getSelection(): Selection

Returns the primary selection of the editor.

§

getSelections(): Selection[]

Returns all the selections of the editor.

§

getSupportedActions(): IEditorAction[]

Returns all actions associated with this editor.

§

getVisibleColumnFromPosition(position: IPosition): number

Given a position, returns a column number that takes tab-widths into account.

§

goToDiff(target: "next" | "previous"): void

Jumps to the next or previous diff.

§

handleInitialized(): void

§

hasTextFocus(): boolean

Returns true if the text inside this editor is focused (i.e. cursor is blinking).

§

layout(
    dimension?: IDimension,
    postponeRendering?: boolean,
): void

Instructs the editor to remeasure its container. This method should be called when the container of the editor gets resized.

If a dimension is passed in, the passed in value will be used.

By default, this will also render the editor immediately. If you prefer to delay rendering to the next animation frame, use postponeRendering == true.

§

restoreViewState(state: IDiffEditorViewState): void

Restores the view state of the editor from a serializable object generated by saveViewState.

§

revealFirstDiff(): unknown

Scrolls to the first diff. (Waits until the diff computation finished.)

§

revealLine(
    lineNumber: number,
    scrollType?: ScrollType,
): void

Scroll vertically as necessary and reveal a line.

§

revealLineInCenter(
    lineNumber: number,
    scrollType?: ScrollType,
): void

Scroll vertically as necessary and reveal a line centered vertically.

§

revealLineInCenterIfOutsideViewport(
    lineNumber: number,
    scrollType?: ScrollType,
): void

Scroll vertically as necessary and reveal a line centered vertically only if it lies outside the viewport.

§

revealLineNearTop(
    lineNumber: number,
    scrollType?: ScrollType,
): void

Scroll vertically as necessary and reveal a line close to the top of the viewport, optimized for viewing a code definition.

§

revealLines(
    startLineNumber: number,
    endLineNumber: number,
    scrollType?: ScrollType,
): void

Scroll vertically as necessary and reveal lines.

§

revealLinesInCenter(
    lineNumber: number,
    endLineNumber: number,
    scrollType?: ScrollType,
): void

Scroll vertically as necessary and reveal lines centered vertically.

§

revealLinesInCenterIfOutsideViewport(
    lineNumber: number,
    endLineNumber: number,
    scrollType?: ScrollType,
): void

Scroll vertically as necessary and reveal lines centered vertically only if it lies outside the viewport.

§

revealLinesNearTop(
    lineNumber: number,
    endLineNumber: number,
    scrollType?: ScrollType,
): void

Scroll vertically as necessary and reveal lines close to the top of the viewport, optimized for viewing a code definition.

§

revealPosition(
    position: IPosition,
    scrollType?: ScrollType,
): void

Scroll vertically or horizontally as necessary and reveal a position.

§

revealPositionInCenter(
    position: IPosition,
    scrollType?: ScrollType,
): void

Scroll vertically or horizontally as necessary and reveal a position centered vertically.

§

revealPositionInCenterIfOutsideViewport(
    position: IPosition,
    scrollType?: ScrollType,
): void

Scroll vertically or horizontally as necessary and reveal a position centered vertically only if it lies outside the viewport.

§

revealPositionNearTop(
    position: IPosition,
    scrollType?: ScrollType,
): void

Scroll vertically or horizontally as necessary and reveal a position close to the top of the viewport, optimized for viewing a code definition.

§

revealRange(range: IRange, scrollType?: ScrollType): void

Scroll vertically or horizontally as necessary and reveal a range.

§

revealRangeAtTop(
    range: IRange,
    scrollType?: ScrollType,
): void

Scroll vertically or horizontally as necessary and reveal a range at the top of the viewport.

§

revealRangeInCenter(
    range: IRange,
    scrollType?: ScrollType,
): void

Scroll vertically or horizontally as necessary and reveal a range centered vertically.

§

revealRangeInCenterIfOutsideViewport(
    range: IRange,
    scrollType?: ScrollType,
): void

Scroll vertically or horizontally as necessary and reveal a range centered vertically only if it lies outside the viewport.

§

revealRangeNearTop(
    range: IRange,
    scrollType?: ScrollType,
): void

Scroll vertically or horizontally as necessary and reveal a range close to the top of the viewport, optimized for viewing a code definition.

§

revealRangeNearTopIfOutsideViewport(
    range: IRange,
    scrollType?: ScrollType,
): void

Scroll vertically or horizontally as necessary and reveal a range close to the top of the viewport, optimized for viewing a code definition. Only if it lies outside the viewport.

§

saveViewState(): IDiffEditorViewState

Saves current view state of the editor in a serializable object.

§

setModel(
    model: IDiffEditorModel | IDiffEditorViewModel,
): void

Sets the current model attached to this editor. If the previous model was created by the editor via the value key in the options literal object, it will be destroyed. Otherwise, if the previous model was set via setModel, or the model key in the options literal object, the previous model will not be destroyed. It is safe to call setModel(null) to simply detach the current model from the editor.

§

setPosition(position: IPosition, source?: string): void

Set the primary position of the cursor. This will remove any secondary cursors.

§

setSelection(selection: IRange, source?: string): void

Set the primary selection of the editor. This will remove any secondary cursors.

§

setSelection(selection: Range, source?: string): void

Set the primary selection of the editor. This will remove any secondary cursors.

§

setSelection(selection: ISelection, source?: string): void

Set the primary selection of the editor. This will remove any secondary cursors.

§

setSelection(selection: Selection, source?: string): void

Set the primary selection of the editor. This will remove any secondary cursors.

§

setSelections(
    selections: readonly ISelection[],
    source?: string,
): void

Set the selections for all the cursors of the editor. Cursors will be removed or added, as necessary.

§

trigger(
    source: string,
    handlerId: string,
    payload: unknown,
): void

Directly trigger a handler or an editor action.

§

updateOptions(newOptions: IDiffEditorOptions): void

Update the editor's options after the editor has been created.

Events§

§readonly onDidChangeModel: IEvent<void>

An event emitted when the diff model is changed (i.e. the diff editor shows new content).

§readonly onDidUpdateDiff: IEvent<void>

An event emitted when the diff information computed by this diff editor has been updated.

§

onDidDispose(listener: () => void): IDisposable

An event emitted when the editor has been disposed.