← Winnitude! Search  ·  Reader Mode (821 ms)
Links: Stay in Reader Retro Site Converter Retro Mode: OFF Original Page ↗
GITHUB · 6 LINKS

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, 2026

Hi,

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions