Skip to content

Commit c5b88e0

Browse files
rostawumpz
authored andcommitted
Proposal/issue 44 (java-diff-utils#45)
* Correction of problem It appears that the configuration reportLinesUnchanged has no effect when showInlineDiffs is true. That is '<' and '>' characters are converted to HTML entities regardless. * Implement rawValues option * Revert "Implement rawValues option" This reverts commit d9c302c.
1 parent f3ff104 commit c5b88e0

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

src/main/java/com/github/difflib/text/DiffRowGenerator.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,11 @@ private DiffRow buildDiffRowWithoutNormalizing(Tag type, String orgline, String
267267
}
268268

269269
List<String> normalizeLines(List<String> list) {
270-
return list.stream()
271-
.map(lineNormalizer::apply)
272-
.collect(toList());
270+
return reportLinesUnchanged
271+
? list
272+
: list.stream()
273+
.map(lineNormalizer::apply)
274+
.collect(toList());
273275
}
274276

275277
/**

src/test/java/com/github/difflib/text/DiffRowGeneratorTest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,4 +405,16 @@ public void testGeneratorIssue41UserNormalizer() throws DiffException {
405405
rows = generator.generateDiffRows(Arrays.asList("\t<"), Arrays.asList("<"));
406406
assertEquals("[[CHANGE, <,<]]", rows.toString());
407407
}
408+
409+
@Test
410+
public void testGenerationIssue44reportLinesUnchangedProblem() throws DiffException {
411+
DiffRowGenerator generator = DiffRowGenerator.create()
412+
.showInlineDiffs(true)
413+
.reportLinesUnchanged(true)
414+
.oldTag(f -> "~~")
415+
.newTag(f -> "**")
416+
.build();
417+
List<DiffRow> rows = generator.generateDiffRows(Arrays.asList("<dt>To do</dt>"), Arrays.asList("<dt>Done</dt>"));
418+
assertEquals("[[CHANGE,<dt>~~T~~o~~ do~~</dt>,<dt>**D**o**ne**</dt>]]", rows.toString());
419+
}
408420
}

0 commit comments

Comments
 (0)