Skip to content

Commit e37a523

Browse files
committed
fixes #66
1 parent fb7fca6 commit e37a523

File tree

3 files changed

+42
-1
lines changed

3 files changed

+42
-1
lines changed

java-diff-utils/src/main/java/com/github/difflib/text/DiffRowGenerator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ private List<DiffRow> generateInlineDiffs(AbstractDelta<String> delta) throws Di
291291
origList = inlineDiffSplitter.apply(joinedOrig);
292292
revList = inlineDiffSplitter.apply(joinedRev);
293293

294-
List<AbstractDelta<String>> inlineDeltas = DiffUtils.diff(origList, revList).getDeltas();
294+
List<AbstractDelta<String>> inlineDeltas = DiffUtils.diff(origList, revList, equalizer).getDeltas();
295295

296296
Collections.reverse(inlineDeltas);
297297
for (AbstractDelta<String> inlineDelta : inlineDeltas) {

java-diff-utils/src/test/java/com/github/difflib/text/DiffRowGeneratorTest.java

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,4 +417,44 @@ public void testGenerationIssue44reportLinesUnchangedProblem() throws DiffExcept
417417
List<DiffRow> rows = generator.generateDiffRows(Arrays.asList("<dt>To do</dt>"), Arrays.asList("<dt>Done</dt>"));
418418
assertEquals("[[CHANGE,<dt>~~T~~o~~ do~~</dt>,<dt>**D**o**ne**</dt>]]", rows.toString());
419419
}
420+
421+
@Test
422+
public void testIgnoreWhitespaceIssue66() throws DiffException {
423+
DiffRowGenerator generator = DiffRowGenerator.create()
424+
.showInlineDiffs(true)
425+
.inlineDiffByWord(true)
426+
.ignoreWhiteSpaces(true)
427+
.mergeOriginalRevised(true)
428+
.oldTag(f -> "~") //introduce markdown style for strikethrough
429+
.newTag(f -> "**") //introduce markdown style for bold
430+
.build();
431+
432+
//compute the differences for two test texts.
433+
//CHECKSTYLE:OFF
434+
List<DiffRow> rows = generator.generateDiffRows(
435+
Arrays.asList("This\tis\ta\ttest."),
436+
Arrays.asList("This is a test"));
437+
//CHECKSTYLE:ON
438+
439+
assertEquals("This is a test~.~", rows.get(0).getOldLine());
440+
}
441+
442+
@Test
443+
public void testIgnoreWhitespaceIssue66_2() throws DiffException {
444+
DiffRowGenerator generator = DiffRowGenerator.create()
445+
.showInlineDiffs(true)
446+
.inlineDiffByWord(true)
447+
.ignoreWhiteSpaces(true)
448+
.mergeOriginalRevised(true)
449+
.oldTag(f -> "~") //introduce markdown style for strikethrough
450+
.newTag(f -> "**") //introduce markdown style for bold
451+
.build();
452+
453+
//compute the differences for two test texts.
454+
List<DiffRow> rows = generator.generateDiffRows(
455+
Arrays.asList("This is a test."),
456+
Arrays.asList("This is a test"));
457+
458+
assertEquals("This is a test~.~", rows.get(0).getOldLine());
459+
}
420460
}

pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@
141141
<module name="SuppressWarningsFilter" />
142142
<module name="FileTabCharacter" />
143143
<module name="TreeWalker">
144+
<module name="SuppressionCommentFilter"/>
144145
<module name="AvoidNestedBlocks" />
145146
<module name="ConstantName" />
146147
<module name="EmptyCatchBlock" />

0 commit comments

Comments
 (0)