make columnwith 0, meaning no text wrap, the standard

This commit is contained in:
wumpz
2017-09-28 13:25:54 +02:00
parent aed1d31c2b
commit 88146c6afb
4 changed files with 8 additions and 5 deletions

View File

@@ -76,7 +76,7 @@ public class DiffRowGenerator {
private Function<Boolean, String> oldTag = f -> f ? "<span class=\"editOldInline\">" : "</span>";
private Function<Boolean, String> newTag = f -> f ? "<span class=\"editNewInline\">" : "</span>";
private int columnWidth = 80;
private int columnWidth = 0;
private boolean mergeOriginalRevised = false;
private boolean inlineDiffByWord = false;
private boolean reportLinesUnchanged = false;

View File

@@ -58,8 +58,11 @@ final class StringUtils {
* @return the wrapped text
*/
public static String wrapText(String line, int columnWidth) {
if (columnWidth <= 0) {
throw new IllegalArgumentException("columnWidth may not be less or equal 0");
if (columnWidth < 0) {
throw new IllegalArgumentException("columnWidth may not be less 0");
}
if (columnWidth == 0) {
return line;
}
int length = line.length();
int delimiter = "<br/>".length();

View File

@@ -173,6 +173,7 @@ public class DiffRowGeneratorTest {
.showInlineDiffs(true)
.mergeOriginalRevised(true)
.inlineDiffByWord(true)
.columnWidth(80)
.build();
List<DiffRow> rows = generator.generateDiffRows(Arrays.asList("Test feature"),Arrays.asList("ester feature best"));
print(rows);

View File

@@ -15,7 +15,6 @@
*/
package com.github.difflib.text;
import com.github.difflib.text.StringUtils;
import java.util.Collections;
import org.junit.Test;
import static org.junit.Assert.*;
@@ -62,7 +61,7 @@ public class StringUtilsTest {
@Test(expected = IllegalArgumentException.class)
public void testWrapText_String_int_zero() {
assertEquals("test", StringUtils.wrapText("test", 0));
assertEquals("test", StringUtils.wrapText("test", -1));
}
}