mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-03 17:23:42 -05:00
Add reverse color option to text diff editor (#4826)
* Add reverse color option to text diff editor
This commit is contained in:
@@ -40,6 +40,8 @@ import { ServiceCollection } from 'vs/platform/instantiation/common/serviceColle
|
||||
import { INotificationService } from 'vs/platform/notification/common/notification';
|
||||
import { defaultInsertColor, defaultRemoveColor, diffBorder, diffInserted, diffInsertedOutline, diffRemoved, diffRemovedOutline, scrollbarShadow } from 'vs/platform/theme/common/colorRegistry';
|
||||
import { ITheme, IThemeService, getThemeTypeSelector, registerThemingParticipant } from 'vs/platform/theme/common/themeService';
|
||||
// {{SQL CARBON EDIT}}
|
||||
import { reverseLineChanges } from 'sql/editor/browser/DiffEditorHelper';
|
||||
|
||||
interface IEditorDiffDecorations {
|
||||
decorations: IModelDeltaDecoration[];
|
||||
@@ -61,7 +63,8 @@ interface IEditorsZones {
|
||||
}
|
||||
|
||||
interface IDiffEditorWidgetStyle {
|
||||
getEditorsDiffDecorations(lineChanges: editorCommon.ILineChange[], ignoreTrimWhitespace: boolean, renderIndicators: boolean, originalWhitespaces: IEditorWhitespace[], modifiedWhitespaces: IEditorWhitespace[], originalEditor: editorBrowser.ICodeEditor, modifiedEditor: editorBrowser.ICodeEditor): IEditorsDiffDecorationsWithZones;
|
||||
// {{SQL CARBON EDIT}}
|
||||
getEditorsDiffDecorations(lineChanges: editorCommon.ILineChange[], ignoreTrimWhitespace: boolean, renderIndicators: boolean, originalWhitespaces: IEditorWhitespace[], modifiedWhitespaces: IEditorWhitespace[], originalEditor: editorBrowser.ICodeEditor, modifiedEditor: editorBrowser.ICodeEditor, reverse?: boolean): IEditorsDiffDecorationsWithZones;
|
||||
setEnableSplitViewResizing(enableSplitViewResizing: boolean): void;
|
||||
applyColors(theme: ITheme): boolean;
|
||||
layout(): number;
|
||||
@@ -193,6 +196,8 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
|
||||
private readonly _notificationService: INotificationService;
|
||||
|
||||
private readonly _reviewPane: DiffReview;
|
||||
// {{SQL CARBON EDIT}}
|
||||
private _options: editorOptions.IDiffEditorOptions;
|
||||
|
||||
constructor(
|
||||
domElement: HTMLElement,
|
||||
@@ -212,6 +217,8 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
|
||||
this._contextKeyService.createKey('isInDiffEditor', true);
|
||||
this._themeService = themeService;
|
||||
this._notificationService = notificationService;
|
||||
// {{SQL CARBON EDIT}}
|
||||
this._options = options;
|
||||
|
||||
this.id = (++DIFF_EDITOR_ID);
|
||||
|
||||
@@ -927,7 +934,8 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
|
||||
let foreignOriginal = this._originalEditorState.getForeignViewZones(this.originalEditor.getWhitespaces());
|
||||
let foreignModified = this._modifiedEditorState.getForeignViewZones(this.modifiedEditor.getWhitespaces());
|
||||
|
||||
let diffDecorations = this._strategy.getEditorsDiffDecorations(lineChanges, this._ignoreTrimWhitespace, this._renderIndicators, foreignOriginal, foreignModified, this.originalEditor, this.modifiedEditor);
|
||||
// {{SQL CARBON EDIT}}
|
||||
let diffDecorations = this._strategy.getEditorsDiffDecorations(lineChanges, this._ignoreTrimWhitespace, this._renderIndicators, foreignOriginal, foreignModified, this.originalEditor, this.modifiedEditor, this._options.reverse);
|
||||
|
||||
try {
|
||||
this._currentlyChangingViewZones = true;
|
||||
@@ -1203,7 +1211,8 @@ abstract class DiffEditorWidgetStyle extends Disposable implements IDiffEditorWi
|
||||
return hasChanges;
|
||||
}
|
||||
|
||||
public getEditorsDiffDecorations(lineChanges: editorCommon.ILineChange[], ignoreTrimWhitespace: boolean, renderIndicators: boolean, originalWhitespaces: IEditorWhitespace[], modifiedWhitespaces: IEditorWhitespace[], originalEditor: editorBrowser.ICodeEditor, modifiedEditor: editorBrowser.ICodeEditor): IEditorsDiffDecorationsWithZones {
|
||||
// {{SQL CARBON EDIT}}
|
||||
public getEditorsDiffDecorations(lineChanges: editorCommon.ILineChange[], ignoreTrimWhitespace: boolean, renderIndicators: boolean, originalWhitespaces: IEditorWhitespace[], modifiedWhitespaces: IEditorWhitespace[], originalEditor: editorBrowser.ICodeEditor, modifiedEditor: editorBrowser.ICodeEditor, reverse?: boolean): IEditorsDiffDecorationsWithZones {
|
||||
// Get view zones
|
||||
modifiedWhitespaces = modifiedWhitespaces.sort((a, b) => {
|
||||
return a.afterLineNumber - b.afterLineNumber;
|
||||
@@ -1213,10 +1222,21 @@ abstract class DiffEditorWidgetStyle extends Disposable implements IDiffEditorWi
|
||||
});
|
||||
let zones = this._getViewZones(lineChanges, originalWhitespaces, modifiedWhitespaces, originalEditor, modifiedEditor, renderIndicators);
|
||||
|
||||
// {{SQL CARBON EDIT}}
|
||||
if (reverse) {
|
||||
lineChanges = reverseLineChanges(lineChanges);
|
||||
[originalEditor, modifiedEditor] = [modifiedEditor, originalEditor];
|
||||
}
|
||||
|
||||
// Get decorations & overview ruler zones
|
||||
let originalDecorations = this._getOriginalEditorDecorations(lineChanges, ignoreTrimWhitespace, renderIndicators, originalEditor, modifiedEditor);
|
||||
let modifiedDecorations = this._getModifiedEditorDecorations(lineChanges, ignoreTrimWhitespace, renderIndicators, originalEditor, modifiedEditor);
|
||||
|
||||
// {{SQL CARBON EDIT}}
|
||||
if (reverse) {
|
||||
[originalDecorations, modifiedDecorations] = [modifiedDecorations, originalDecorations];
|
||||
}
|
||||
|
||||
return {
|
||||
original: {
|
||||
decorations: originalDecorations.decorations,
|
||||
|
||||
Reference in New Issue
Block a user