Skip to content
This repository was archived by the owner on Oct 21, 2020. It is now read-only.

Commit 88146c6

Browse files
committed
make columnwith 0, meaning no text wrap, the standard
1 parent aed1d31 commit 88146c6

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public static class Builder {
7676
private Function<Boolean, String> oldTag = f -> f ? "<span class=\"editOldInline\">" : "</span>";
7777
private Function<Boolean, String> newTag = f -> f ? "<span class=\"editNewInline\">" : "</span>";
7878

79-
private int columnWidth = 80;
79+
private int columnWidth = 0;
8080
private boolean mergeOriginalRevised = false;
8181
private boolean inlineDiffByWord = false;
8282
private boolean reportLinesUnchanged = false;

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,11 @@ public static List<String> wrapText(List<String> list, int columnWidth) {
5858
* @return the wrapped text
5959
*/
6060
public static String wrapText(String line, int columnWidth) {
61-
if (columnWidth <= 0) {
62-
throw new IllegalArgumentException("columnWidth may not be less or equal 0");
61+
if (columnWidth < 0) {
62+
throw new IllegalArgumentException("columnWidth may not be less 0");
63+
}
64+
if (columnWidth == 0) {
65+
return line;
6366
}
6467
int length = line.length();
6568
int delimiter = "<br/>".length();

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ public void testGeneratorWithMergeByWord5() throws DiffException {
173173
.showInlineDiffs(true)
174174
.mergeOriginalRevised(true)
175175
.inlineDiffByWord(true)
176+
.columnWidth(80)
176177
.build();
177178
List<DiffRow> rows = generator.generateDiffRows(Arrays.asList("Test feature"),Arrays.asList("ester feature best"));
178179
print(rows);

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
*/
1616
package com.github.difflib.text;
1717

18-
import com.github.difflib.text.StringUtils;
1918
import java.util.Collections;
2019
import org.junit.Test;
2120
import static org.junit.Assert.*;
@@ -62,7 +61,7 @@ public void testWrapText_String_int() {
6261

6362
@Test(expected = IllegalArgumentException.class)
6463
public void testWrapText_String_int_zero() {
65-
assertEquals("test", StringUtils.wrapText("test", 0));
64+
assertEquals("test", StringUtils.wrapText("test", -1));
6665
}
6766

6867
}

0 commit comments

Comments
 (0)