UnifiedDiffUtils.getRowMap parses the revised range from the original range · Issue #247 · java-diff-utils/java-diff-utils
Repository navigation
UnifiedDiffUtils.getRowMap parses the revised range from the original range #247
New issue
New issue
Backlog
Backlog
UnifiedDiffUtils.getRowMap parses the revised range from the original range #247
Description
@Prabhav-dev's profile Prabhav-dev opened on Dec 2, 2026Hi,
While testing UnifiedDiffUtils.getRowMap, I noticed that the revised range in a unified diff hunk header seems to be parsed from the original range instead of the revised one.
In the following code, revSp is initialized using org, which contains the - side of the hunk header:
String[] revSp = org.split(",");
It looks like this should be using sp[2], which contains the + side:
String[] revSp = sp[2].split(",");
For example, with this hunk header:
@@ -10,3 +12,5 @@
I currently get:
revRow = 10
revAdd = 3
But I would expect:
revRow = 12
revAdd = 5
This seems to cause the revised row mapping to be incorrect whenever the original and revised ranges differ.
Would using sp[2] here be the intended fix?
I'm happy to submit a PR for this if you'd like.
Thanks!