From d9c9e8ddfd9530c8f551b9e2a4c1b9a50eb34749 Mon Sep 17 00:00:00 2001 From: Alex Dima Date: Mon, 18 Dec 2017 18:28:21 +0100 Subject: [PATCH] Fixes #18353: Always respect the `shouldIgnoreTrimWhitespace` flag --- src/vs/editor/common/diff/diffComputer.ts | 24 ------------------- .../common/services/editorSimpleWorker.ts | 2 -- .../test/common/diff/diffComputer.test.ts | 1 - 3 files changed, 27 deletions(-) diff --git a/src/vs/editor/common/diff/diffComputer.ts b/src/vs/editor/common/diff/diffComputer.ts index f9c02b3ee116..a1b88e19a4b0 100644 --- a/src/vs/editor/common/diff/diffComputer.ts +++ b/src/vs/editor/common/diff/diffComputer.ts @@ -34,24 +34,6 @@ class MarkerSequence implements ISequence { this.endMarkers = endMarkers; } - public equals(other: any): boolean { - if (!(other instanceof MarkerSequence)) { - return false; - } - const otherMarkerSequence = other; - if (this.getLength() !== otherMarkerSequence.getLength()) { - return false; - } - for (let i = 0, len = this.getLength(); i < len; i++) { - const myElement = this.getElementHash(i); - const otherElement = otherMarkerSequence.getElementHash(i); - if (myElement !== otherElement) { - return false; - } - } - return true; - } - public getLength(): number { return this.startMarkers.length; } @@ -321,7 +303,6 @@ class LineChange implements ILineChange { export interface IDiffComputerOpts { shouldPostProcessCharChanges: boolean; shouldIgnoreTrimWhitespace: boolean; - shouldConsiderTrimWhitespaceInEmptyCase: boolean; shouldMakePrettyDiff: boolean; } @@ -347,11 +328,6 @@ export class DiffComputer { this.modifiedLines = modifiedLines; this.original = new LineMarkerSequence(originalLines); this.modified = new LineMarkerSequence(modifiedLines); - - if (opts.shouldConsiderTrimWhitespaceInEmptyCase && this.shouldIgnoreTrimWhitespace && this.original.equals(this.modified)) { - // Diff would be empty with `shouldIgnoreTrimWhitespace` - this.shouldIgnoreTrimWhitespace = false; - } } public computeDiff(): ILineChange[] { diff --git a/src/vs/editor/common/services/editorSimpleWorker.ts b/src/vs/editor/common/services/editorSimpleWorker.ts index 169df1f0de1a..155f97c34cf3 100644 --- a/src/vs/editor/common/services/editorSimpleWorker.ts +++ b/src/vs/editor/common/services/editorSimpleWorker.ts @@ -313,7 +313,6 @@ export abstract class BaseEditorSimpleWorker { let diffComputer = new DiffComputer(originalLines, modifiedLines, { shouldPostProcessCharChanges: true, shouldIgnoreTrimWhitespace: ignoreTrimWhitespace, - shouldConsiderTrimWhitespaceInEmptyCase: true, shouldMakePrettyDiff: true }); return TPromise.as(diffComputer.computeDiff()); @@ -331,7 +330,6 @@ export abstract class BaseEditorSimpleWorker { let diffComputer = new DiffComputer(originalLines, modifiedLines, { shouldPostProcessCharChanges: false, shouldIgnoreTrimWhitespace: ignoreTrimWhitespace, - shouldConsiderTrimWhitespaceInEmptyCase: false, shouldMakePrettyDiff: true }); return TPromise.as(diffComputer.computeDiff()); diff --git a/src/vs/editor/test/common/diff/diffComputer.test.ts b/src/vs/editor/test/common/diff/diffComputer.test.ts index 54ef2f3a86ed..0d521de7eb85 100644 --- a/src/vs/editor/test/common/diff/diffComputer.test.ts +++ b/src/vs/editor/test/common/diff/diffComputer.test.ts @@ -55,7 +55,6 @@ function assertDiff(originalLines: string[], modifiedLines: string[], expectedCh var diffComputer = new DiffComputer(originalLines, modifiedLines, { shouldPostProcessCharChanges: shouldPostProcessCharChanges || false, shouldIgnoreTrimWhitespace: shouldIgnoreTrimWhitespace || false, - shouldConsiderTrimWhitespaceInEmptyCase: true, shouldMakePrettyDiff: true }); var changes = diffComputer.computeDiff();