Skip to content

Commit ca0abe6

Browse files
committed
Small diff editor refactoring
1 parent 898311b commit ca0abe6

File tree

5 files changed

+29
-18
lines changed

5 files changed

+29
-18
lines changed

src/vs/editor/browser/editorBrowser.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { IEditorWhitespace, IViewModel } from 'vs/editor/common/viewModel';
2121
import { InjectedText } from 'vs/editor/common/modelLineProjectionData';
2222
import { ILineChange, IDiffComputationResult } from 'vs/editor/common/diff/smartLinesDiffComputer';
2323
import { IDimension } from 'vs/editor/common/core/dimension';
24+
import { IBoundarySashes } from 'vs/base/browser/ui/sash/sash';
2425

2526
/**
2627
* A view zone is a full horizontal rectangle that 'pushes' text down.
@@ -1210,6 +1211,11 @@ export interface IDiffEditor extends editorCommon.IEditor {
12101211
* Update the editor's options after the editor has been created.
12111212
*/
12121213
updateOptions(newOptions: IDiffEditorOptions): void;
1214+
1215+
/**
1216+
* @internal
1217+
*/
1218+
setBoundarySashes(sashes: IBoundarySashes): void;
12131219
}
12141220

12151221
/**

src/vs/editor/browser/widget/diffEditorWidget.ts

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -866,6 +866,8 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
866866
return this._domElement;
867867
}
868868

869+
// #region editorBrowser.IDiffEditor: Delegating to modified Editor
870+
869871
public getVisibleColumnFromPosition(position: IPosition): number {
870872
return this._modifiedEditor.getVisibleColumnFromPosition(position);
871873
}
@@ -978,6 +980,24 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
978980
return this._modifiedEditor.getSupportedActions();
979981
}
980982

983+
public focus(): void {
984+
this._modifiedEditor.focus();
985+
}
986+
987+
public trigger(source: string | null | undefined, handlerId: string, payload: any): void {
988+
this._modifiedEditor.trigger(source, handlerId, payload);
989+
}
990+
991+
public createDecorationsCollection(decorations?: IModelDeltaDecoration[]): editorCommon.IEditorDecorationsCollection {
992+
return this._modifiedEditor.createDecorationsCollection(decorations);
993+
}
994+
995+
public changeDecorations(callback: (changeAccessor: IModelDecorationsChangeAccessor) => any): any {
996+
return this._modifiedEditor.changeDecorations(callback);
997+
}
998+
999+
// #endregion
1000+
9811001
public saveViewState(): editorCommon.IDiffEditorViewState {
9821002
const originalViewState = this._originalEditor.saveViewState();
9831003
const modifiedViewState = this._modifiedEditor.saveViewState();
@@ -999,9 +1019,6 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
9991019
this._elementSizeObserver.observe(dimension);
10001020
}
10011021

1002-
public focus(): void {
1003-
this._modifiedEditor.focus();
1004-
}
10051022

10061023
public hasTextFocus(): boolean {
10071024
return this._originalEditor.hasTextFocus() || this._modifiedEditor.hasTextFocus();
@@ -1023,18 +1040,6 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
10231040
this._cleanViewZonesAndDecorations();
10241041
}
10251042

1026-
public trigger(source: string | null | undefined, handlerId: string, payload: any): void {
1027-
this._modifiedEditor.trigger(source, handlerId, payload);
1028-
}
1029-
1030-
public createDecorationsCollection(decorations?: IModelDeltaDecoration[]): editorCommon.IEditorDecorationsCollection {
1031-
return this._modifiedEditor.createDecorationsCollection(decorations);
1032-
}
1033-
1034-
public changeDecorations(callback: (changeAccessor: IModelDecorationsChangeAccessor) => any): any {
1035-
return this._modifiedEditor.changeDecorations(callback);
1036-
}
1037-
10381043
//------------ end IDiffEditor methods
10391044

10401045

src/vs/editor/common/diff/documentDiffProvider.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export interface IDocumentDiffProvider {
2828
*/
2929
export interface IDocumentDiffProviderOptions {
3030
/**
31-
* When set to true, the diff should ignore whitespace changes.i
31+
* When set to true, the diff should ignore whitespace changes.
3232
*/
3333
ignoreTrimWhitespace: boolean;
3434

src/vs/monaco.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2348,7 +2348,7 @@ declare namespace monaco.editor {
23482348
*/
23492349
export interface IDocumentDiffProviderOptions {
23502350
/**
2351-
* When set to true, the diff should ignore whitespace changes.i
2351+
* When set to true, the diff should ignore whitespace changes.
23522352
*/
23532353
ignoreTrimWhitespace: boolean;
23542354
/**

src/vs/workbench/browser/parts/editor/textDiffEditor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export class TextDiffEditor extends AbstractTextEditor<IDiffEditorViewState> imp
4545

4646
static readonly ID = TEXT_DIFF_EDITOR_ID;
4747

48-
private diffEditorControl: DiffEditorWidget | undefined = undefined;
48+
private diffEditorControl: IDiffEditor | undefined = undefined;
4949

5050
private diffNavigator: DiffNavigator | undefined;
5151
private readonly diffNavigatorDisposables = this._register(new DisposableStore());

0 commit comments

Comments
 (0)