@@ -53,8 +53,8 @@ public class DiffRowGenerator {
5353
5454 private final boolean showInlineDiffs ;
5555 private final boolean ignoreWhiteSpaces ;
56- private final Function <Boolean ,String > oldTag ;
57- private final Function <Boolean ,String > newTag ;
56+ private final Function <Boolean , String > oldTag ;
57+ private final Function <Boolean , String > newTag ;
5858 private final boolean inlineDiffByWord ;
5959 private final int columnWidth ;
6060 private final Equalizer <String > equalizer ;
@@ -70,10 +70,10 @@ public static class Builder {
7070
7171 private boolean showInlineDiffs = false ;
7272 private boolean ignoreWhiteSpaces = false ;
73-
74- private Function <Boolean ,String > oldTag = f -> f ? "<span class=\" editOldInline\" >" : "</span>" ;
75- private Function <Boolean ,String > newTag = f -> f ? "<span class=\" editNewInline\" >" : "</span>" ;
76-
73+
74+ private Function <Boolean , String > oldTag = f -> f ? "<span class=\" editOldInline\" >" : "</span>" ;
75+ private Function <Boolean , String > newTag = f -> f ? "<span class=\" editNewInline\" >" : "</span>" ;
76+
7777 private int columnWidth = 80 ;
7878 private boolean mergeOriginalRevised = false ;
7979 private boolean inlineDiffByWord = false ;
@@ -109,17 +109,18 @@ public Builder ignoreWhiteSpaces(boolean val) {
109109 * @param tag the tag to set. Without angle brackets. Default: span.
110110 * @return builder with configured ignoreBlankLines parameter
111111 */
112- public Builder oldTag (Function <Boolean ,String > generator ) {
112+ public Builder oldTag (Function <Boolean , String > generator ) {
113113 this .oldTag = generator ;
114114 return this ;
115115 }
116116
117117 /**
118118 * Generator for New-Text-Tags.
119+ *
119120 * @param generator
120- * @return
121+ * @return
121122 */
122- public Builder newTag (Function <Boolean ,String > generator ) {
123+ public Builder newTag (Function <Boolean , String > generator ) {
123124 this .newTag = generator ;
124125 return this ;
125126 }
@@ -206,12 +207,18 @@ public List<DiffRow> generateDiffRows(List<String> original, List<String> revise
206207
207208 private DiffRow buildDiffRow (Tag type , String orgline , String newline ) {
208209 String wrapOrg = StringUtils .wrapText (StringUtils .normalize (orgline ), columnWidth );
209- if (mergeOriginalRevised && Tag .DELETE == type ) {
210- wrapOrg = oldTag .apply (true ) + wrapOrg + oldTag .apply (false );
210+ if (Tag .DELETE == type ) {
211+ if (mergeOriginalRevised || showInlineDiffs ) {
212+ wrapOrg = oldTag .apply (true ) + wrapOrg + oldTag .apply (false );
213+ }
211214 }
212215 String wrapNew = StringUtils .wrapText (StringUtils .normalize (newline ), columnWidth );
213- if (mergeOriginalRevised && Tag .INSERT == type ) {
214- wrapOrg = newTag .apply (true ) + wrapNew + newTag .apply (false );
216+ if (Tag .INSERT == type ) {
217+ if (mergeOriginalRevised ) {
218+ wrapOrg = newTag .apply (true ) + wrapNew + newTag .apply (false );
219+ } else if (showInlineDiffs ) {
220+ wrapNew = newTag .apply (true ) + wrapNew + newTag .apply (false );
221+ }
215222 }
216223 return new DiffRow (type , wrapOrg , wrapNew );
217224 }
@@ -374,7 +381,7 @@ private List<DiffRow> generateInlineDiffs(Delta<String> delta) throws DiffExcept
374381 * @param cssClass the optional css class
375382 */
376383 public static void wrapInTag (List <String > sequence , int startPosition ,
377- int endPosition , Function <Boolean ,String > generator ) {
384+ int endPosition , Function <Boolean , String > generator ) {
378385 sequence .add (startPosition , generator .apply (true ));
379386 sequence .add (endPosition , generator .apply (false ));
380387 }
0 commit comments