diff --git a/src/vs/workbench/browser/parts/editor/media/IgnoreTrimWhiteSpaceChecked_16x.svg b/src/vs/workbench/browser/parts/editor/media/IgnoreTrimWhiteSpaceChecked_16x.svg
new file mode 100644
index 0000000000000000000000000000000000000000..12a8e9f981a34baeba5481b40816d0d10a8604d8
--- /dev/null
+++ b/src/vs/workbench/browser/parts/editor/media/IgnoreTrimWhiteSpaceChecked_16x.svg
@@ -0,0 +1 @@
+
diff --git a/src/vs/workbench/browser/parts/editor/media/IgnoreTrimWhiteSpaceChecked_16x_inverse.svg b/src/vs/workbench/browser/parts/editor/media/IgnoreTrimWhiteSpaceChecked_16x_inverse.svg
new file mode 100644
index 0000000000000000000000000000000000000000..d44a01472d4bdbb02cdcc9b8f2b535e6bacf5d6f
--- /dev/null
+++ b/src/vs/workbench/browser/parts/editor/media/IgnoreTrimWhiteSpaceChecked_16x_inverse.svg
@@ -0,0 +1 @@
+
diff --git a/src/vs/workbench/browser/parts/editor/media/IgnoreTrimWhiteSpace_16x.svg b/src/vs/workbench/browser/parts/editor/media/IgnoreTrimWhiteSpace_16x.svg
new file mode 100644
index 0000000000000000000000000000000000000000..05b193a5d028d497a5d0f5fda4d170eda67c9389
--- /dev/null
+++ b/src/vs/workbench/browser/parts/editor/media/IgnoreTrimWhiteSpace_16x.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/src/vs/workbench/browser/parts/editor/media/IgnoreTrimWhiteSpace_16x_inverse.svg b/src/vs/workbench/browser/parts/editor/media/IgnoreTrimWhiteSpace_16x_inverse.svg
new file mode 100644
index 0000000000000000000000000000000000000000..3b904eafa79a9995ce59f6d305b5d94a56774033
--- /dev/null
+++ b/src/vs/workbench/browser/parts/editor/media/IgnoreTrimWhiteSpace_16x_inverse.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/src/vs/workbench/browser/parts/editor/media/textdiffeditor.css b/src/vs/workbench/browser/parts/editor/media/textdiffeditor.css
index 58ac50f9b94f34f0e1ec3834a068a3bc93a8163d..86c6b735e47464516a5617ff22a3123164b527ec 100644
--- a/src/vs/workbench/browser/parts/editor/media/textdiffeditor.css
+++ b/src/vs/workbench/browser/parts/editor/media/textdiffeditor.css
@@ -19,4 +19,20 @@
.vs-dark .monaco-workbench .textdiff-editor-action.previous,
.hc-black .monaco-workbench .textdiff-editor-action.previous {
background: url('previous-diff-inverse.svg') center center no-repeat;
-}
\ No newline at end of file
+}
+
+.vs .monaco-workbench .textdiff-editor-action.toggleIgnoreTrimWhitespace {
+ background: url('IgnoreTrimWhiteSpace_16x.svg') center center no-repeat;
+}
+.vs-dark .monaco-workbench .textdiff-editor-action.toggleIgnoreTrimWhitespace,
+.hc-black .monaco-workbench .textdiff-editor-action.toggleIgnoreTrimWhitespace {
+ background: url('IgnoreTrimWhiteSpace_16x_inverse.svg ') center center no-repeat;
+}
+
+.vs .monaco-workbench .textdiff-editor-action.toggleIgnoreTrimWhitespace.is-checked {
+ background: url('IgnoreTrimWhiteSpaceChecked_16x.svg') center center no-repeat;
+}
+.vs-dark .monaco-workbench .textdiff-editor-action.toggleIgnoreTrimWhitespace.is-checked,
+.hc-black .monaco-workbench .textdiff-editor-action.toggleIgnoreTrimWhitespace.is-checked {
+ background: url('IgnoreTrimWhiteSpaceChecked_16x_inverse.svg ') center center no-repeat;
+}
diff --git a/src/vs/workbench/browser/parts/editor/textDiffEditor.ts b/src/vs/workbench/browser/parts/editor/textDiffEditor.ts
index d940c64917c264ee4b9d2b66cbcc6697539c74e7..026b8f1b8fe925aaba4d371ea81eeb2f8927601a 100644
--- a/src/vs/workbench/browser/parts/editor/textDiffEditor.ts
+++ b/src/vs/workbench/browser/parts/editor/textDiffEditor.ts
@@ -34,6 +34,8 @@ import { IEditorGroupService } from 'vs/workbench/services/group/common/groupSer
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
import { IEditorInput } from 'vs/platform/editor/common/editor';
import { ScrollType } from 'vs/editor/common/editorCommon';
+import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
+import { IDisposable } from 'vs/base/common/lifecycle';
/**
* The text editor that leverages the diff text editor for the editing experience.
@@ -45,18 +47,27 @@ export class TextDiffEditor extends BaseTextEditor {
private diffNavigator: DiffNavigator;
private nextDiffAction: NavigateAction;
private previousDiffAction: NavigateAction;
+ private toggleIgnoreTrimWhitespaceAction: ToggleIgnoreTrimWhitespaceAction;
+ private _configurationListener: IDisposable;
constructor(
@ITelemetryService telemetryService: ITelemetryService,
@IInstantiationService instantiationService: IInstantiationService,
@IStorageService storageService: IStorageService,
@ITextResourceConfigurationService configurationService: ITextResourceConfigurationService,
+ @IConfigurationService private readonly _actualConfigurationService: IConfigurationService,
@IWorkbenchEditorService private editorService: IWorkbenchEditorService,
@IThemeService themeService: IThemeService,
@IEditorGroupService editorGroupService: IEditorGroupService,
@ITextFileService textFileService: ITextFileService
) {
super(TextDiffEditor.ID, telemetryService, instantiationService, storageService, configurationService, themeService, textFileService, editorGroupService);
+
+ this._configurationListener = this._actualConfigurationService.onDidChangeConfiguration((e) => {
+ if (e.affectsConfiguration('diffEditor.ignoreTrimWhitespace')) {
+ this.updateIgnoreTrimWhitespaceAction();
+ }
+ });
}
public getTitle(): string {
@@ -72,6 +83,8 @@ export class TextDiffEditor extends BaseTextEditor {
// Actions
this.nextDiffAction = new NavigateAction(this, true);
this.previousDiffAction = new NavigateAction(this, false);
+ this.toggleIgnoreTrimWhitespaceAction = new ToggleIgnoreTrimWhitespaceAction(this._actualConfigurationService);
+ this.updateIgnoreTrimWhitespaceAction();
// Support navigation within the diff editor by overriding the editor service within
const delegatingEditorService = this.instantiationService.createInstance(DelegatingWorkbenchEditorService);
@@ -163,6 +176,7 @@ export class TextDiffEditor extends BaseTextEditor {
this.nextDiffAction.updateEnablement();
this.previousDiffAction.updateEnablement();
});
+ this.updateIgnoreTrimWhitespaceAction();
}, error => {
// In case we tried to open a file and the response indicates that this is not a text file, fallback to binary diff.
@@ -176,6 +190,13 @@ export class TextDiffEditor extends BaseTextEditor {
});
}
+ private updateIgnoreTrimWhitespaceAction(): void {
+ const ignoreTrimWhitespace = this.configurationService.getValue(this.getResource(), 'diffEditor.ignoreTrimWhitespace');
+ if (this.toggleIgnoreTrimWhitespaceAction) {
+ this.toggleIgnoreTrimWhitespaceAction.updateClassName(ignoreTrimWhitespace);
+ }
+ }
+
private openAsBinary(input: EditorInput, options: EditorOptions): boolean {
if (input instanceof DiffEditorInput) {
const originalInput = input.originalInput;
@@ -273,6 +294,7 @@ export class TextDiffEditor extends BaseTextEditor {
public getActions(): IAction[] {
return [
+ this.toggleIgnoreTrimWhitespaceAction,
this.previousDiffAction,
this.nextDiffAction
];
@@ -303,6 +325,8 @@ export class TextDiffEditor extends BaseTextEditor {
this.diffNavigator.dispose();
}
+ this._configurationListener.dispose();
+
super.dispose();
}
}
@@ -340,6 +364,29 @@ class NavigateAction extends Action {
}
}
+class ToggleIgnoreTrimWhitespaceAction extends Action {
+ static ID = 'workbench.action.compareEditor.toggleIgnoreTrimWhitespace';
+
+ private _isChecked: boolean;
+
+ constructor(
+ @IConfigurationService private readonly _configurationService: IConfigurationService
+ ) {
+ super(ToggleIgnoreTrimWhitespaceAction.ID);
+ this.label = nls.localize('toggleIgnoreTrimWhitespace.label', "Ignore Trim Whitespace");
+ }
+
+ public updateClassName(ignoreTrimWhitespace: boolean): void {
+ this._isChecked = ignoreTrimWhitespace;
+ this.class = `textdiff-editor-action toggleIgnoreTrimWhitespace${this._isChecked ? ' is-checked' : ''}`;
+ }
+
+ public run(): TPromise {
+ this._configurationService.updateValue(`diffEditor.ignoreTrimWhitespace`, !this._isChecked);
+ return null;
+ }
+}
+
class ToggleEditorModeAction extends Action {
private static readonly ID = 'toggle.diff.editorMode';
private static readonly INLINE_LABEL = nls.localize('inlineDiffLabel', "Switch to Inline View");