Small diff editor refactoring

This commit is contained in:
Henning Dieterichs 2023-05-23 15:17:02 +02:00
parent 898311b454
commit ca0abe62ff
No known key found for this signature in database
GPG key ID: 771381EFFDB9EC06
5 changed files with 29 additions and 18 deletions

View file

@ -21,6 +21,7 @@ import { IEditorWhitespace, IViewModel } from 'vs/editor/common/viewModel';
import { InjectedText } from 'vs/editor/common/modelLineProjectionData';
import { ILineChange, IDiffComputationResult } from 'vs/editor/common/diff/smartLinesDiffComputer';
import { IDimension } from 'vs/editor/common/core/dimension';
import { IBoundarySashes } from 'vs/base/browser/ui/sash/sash';
/**
* A view zone is a full horizontal rectangle that 'pushes' text down.
@ -1210,6 +1211,11 @@ export interface IDiffEditor extends editorCommon.IEditor {
* Update the editor's options after the editor has been created.
*/
updateOptions(newOptions: IDiffEditorOptions): void;
/**
* @internal
*/
setBoundarySashes(sashes: IBoundarySashes): void;
}
/**

View file

@ -866,6 +866,8 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
return this._domElement;
}
// #region editorBrowser.IDiffEditor: Delegating to modified Editor
public getVisibleColumnFromPosition(position: IPosition): number {
return this._modifiedEditor.getVisibleColumnFromPosition(position);
}
@ -978,6 +980,24 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
return this._modifiedEditor.getSupportedActions();
}
public focus(): void {
this._modifiedEditor.focus();
}
public trigger(source: string | null | undefined, handlerId: string, payload: any): void {
this._modifiedEditor.trigger(source, handlerId, payload);
}
public createDecorationsCollection(decorations?: IModelDeltaDecoration[]): editorCommon.IEditorDecorationsCollection {
return this._modifiedEditor.createDecorationsCollection(decorations);
}
public changeDecorations(callback: (changeAccessor: IModelDecorationsChangeAccessor) => any): any {
return this._modifiedEditor.changeDecorations(callback);
}
// #endregion
public saveViewState(): editorCommon.IDiffEditorViewState {
const originalViewState = this._originalEditor.saveViewState();
const modifiedViewState = this._modifiedEditor.saveViewState();
@ -999,9 +1019,6 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
this._elementSizeObserver.observe(dimension);
}
public focus(): void {
this._modifiedEditor.focus();
}
public hasTextFocus(): boolean {
return this._originalEditor.hasTextFocus() || this._modifiedEditor.hasTextFocus();
@ -1023,18 +1040,6 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
this._cleanViewZonesAndDecorations();
}
public trigger(source: string | null | undefined, handlerId: string, payload: any): void {
this._modifiedEditor.trigger(source, handlerId, payload);
}
public createDecorationsCollection(decorations?: IModelDeltaDecoration[]): editorCommon.IEditorDecorationsCollection {
return this._modifiedEditor.createDecorationsCollection(decorations);
}
public changeDecorations(callback: (changeAccessor: IModelDecorationsChangeAccessor) => any): any {
return this._modifiedEditor.changeDecorations(callback);
}
//------------ end IDiffEditor methods

View file

@ -28,7 +28,7 @@ export interface IDocumentDiffProvider {
*/
export interface IDocumentDiffProviderOptions {
/**
* When set to true, the diff should ignore whitespace changes.i
* When set to true, the diff should ignore whitespace changes.
*/
ignoreTrimWhitespace: boolean;

2
src/vs/monaco.d.ts vendored
View file

@ -2348,7 +2348,7 @@ declare namespace monaco.editor {
*/
export interface IDocumentDiffProviderOptions {
/**
* When set to true, the diff should ignore whitespace changes.i
* When set to true, the diff should ignore whitespace changes.
*/
ignoreTrimWhitespace: boolean;
/**

View file

@ -45,7 +45,7 @@ export class TextDiffEditor extends AbstractTextEditor<IDiffEditorViewState> imp
static readonly ID = TEXT_DIFF_EDITOR_ID;
private diffEditorControl: DiffEditorWidget | undefined = undefined;
private diffEditorControl: IDiffEditor | undefined = undefined;
private diffNavigator: DiffNavigator | undefined;
private readonly diffNavigatorDisposables = this._register(new DisposableStore());