Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork201
Open
Description
When usingDiffRowGenerator
withinlineDiffByWord(false)
for character-level diff, the marked differences are not correctly aligned. Specifically, when comparing "aaaab"and "bbbbb", the output is:
Old:aaaab(correct)
New: bbbbb(incorrect, expectedbbbbb)
This suggests that the diff algorithm is not strictly aligning changes by character position.
Demo code:
importcom.github.difflib.DiffUtils;importcom.github.difflib.algorithm.myers.MyersDiff;importcom.github.difflib.text.DiffRow;importcom.github.difflib.text.DiffRowGenerator;importjava.util.List;publicclassDiffExample {publicstaticvoidmain(String[]args) {DiffRowGeneratorgenerator =DiffRowGenerator.create() .showInlineDiffs(true) .inlineDiffByWord(false) .ignoreWhiteSpaces(false) .oldTag(f ->"~") .newTag(f ->"**") .build();List<DiffRow>rows =generator.generateDiffRows(List.of("aaaab"),List.of("bbbbb") );System.out.println("Old: " +rows.get(0).getOldLine());// Actual: ~aaaa~bSystem.out.println("New: " +rows.get(0).getNewLine());// Actual: b**bbbb** (Expected: **bbbb**b) }}
Metadata
Metadata
Assignees
Labels
No labels