curran / curran/google-diff-match-patch
diff_cleanupMerge() could be improved
- Dominant language
- Python
- Stars
- 17
- Forks
- 2
- PR merge metrics
- No merged PRs in 30d
Description
```
Here are some cases I've discovered where diff_cleanupMerge() could do a better
job.
Probably it's not the best place to put those fixes. Or maybe such situations
will never happen upstream in diff itself. Please let me know then.
// this works already
diffs = diffList(new Diff(EQUAL, "g"), new Diff(DELETE, "gg"), new Diff(EQUAL,
"abc"));
dmp.diff_cleanupMerge(diffs);
assertEquals("diff_cleanupMerge: Deletion move left.",
diffList(new Diff(DELETE, "gg"), new Diff(EQUAL, "gabc")), diffs);
// but this and the other two cases - don't
diffs = diffList(new Diff(EQUAL, "gg"), new Diff(DELETE, "g"), new Diff(EQUAL,
"abc"));
dmp.diff_cleanupMerge(diffs);
assertEquals("diff_cleanupMerge: Deletion multi-move left.",
diffList(new Diff(DELETE, "g"), new Diff(EQUAL, "ggabc")), diffs);
diffs = diffList(new Diff(EQUAL, "gdgd"), new Diff(DELETE, "gd"), new
Diff(EQUAL, "abc"));
dmp.diff_cleanupMerge(diffs);
assertEquals("diff_cleanupMerge: Deletion multi-move left.",
diffList(new Diff(DELETE, "gd"), new Diff(EQUAL, "gdgdabc")), diffs);
diffs = diffList(new Diff(EQUAL, "ggg"), new Diff(DELETE, "gg"), new
Diff(EQUAL, "abc"));
dmp.diff_cleanupMerge(diffs);
assertEquals("diff_cleanupMerge: Deletion tricky move left.",
diffList(new Diff(DELETE, "gg"), new Diff(EQUAL, "gggabc")), diffs);
The same applies to right shifts too.
```
Original issue reported on code.google.com by `2sa...@gmail.com` on 10 Jul 2012 at 9:43
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.