mirror of
https://github.com/java-diff-utils/java-diff-utils.git
synced 2026-03-13 10:11:17 +08:00
make columnwith 0, meaning no text wrap, the standard
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user