Feature Request - To Merge Differences
gvjoshi25 opened this issue · comments
Describe the Feature
A new request to consider including whitespace (space in my case) to represent the differences.
To Reproduce
Steps to reproduce the behavior:
- Example data --> Included in snippet.
- simple program snippet
import java.util.Arrays;
import java.util.List;
import com.github.difflib.text.DiffRow;
import com.github.difflib.text.DiffRowGenerator;
public class ShowDiffViewUsingJavaDiffUtils {
static String leftString = "A sample string to test this tool.";
static String rightString = "A sample string is defined here and will be used to test diff library.";
public static void main(String[] args) throws Throwable {
//create a configured DiffRowGenerator
DiffRowGenerator generator = DiffRowGenerator.create()
.ignoreWhiteSpaces(true)
.showInlineDiffs(true)
.mergeOriginalRevised(false)
.inlineDiffByWord(true)
.oldTag(f -> "--")
.newTag(f -> "++")
.build();
//compute the differences for two test texts.
List<DiffRow> rows = generator.generateDiffRows(
Arrays.asList(leftString),
Arrays.asList(rightString));
rows.stream().forEach(r -> {
System.out.println("OldLine: " + r.getOldLine());
System.out.println("NewLine: " + r.getNewLine());
});
}
}
- See error - NA.
Expected behavior
The output of my program is:
OldLine: A sample string to test --this-- --tool--.
NewLine: A sample string ++is defined here and will be used ++to test ++diff++ ++library++.
I would like to have this diff tool to consider whitespace. e.g. consider whitespace between this tool
for the differences.
Expected output:
OldLine: A sample string to test --this tool--.
NewLine: A sample string ++is defined here and will be used ++to test ++diff library++.
I have tried all possible configurations to achieve this, but no luck, hence raising this request. If the feature does exist, please share the details.
System
- Java version - 1.8
- Version - 4.12
Stale issue message