Skip to content

UnifiedDiffUtils.getRowMap parses the revised range from the original range #247

Backlog

Description

@Prabhav-dev

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!

Activity

  1. changed the title [-]## `UnifiedDiffUtils.getRowMap` parses the revised range from the original range[/-] [+]UnifiedDiffUtils.getRowMap` parses the revised range from the original range[/+] on Dec 2, 2026
  2. changed the title [-]UnifiedDiffUtils.getRowMap` parses the revised range from the original range[/-] [+]UnifiedDiffUtils.getRowMap parses the revised range from the original range[/+] on Dec 2, 2026
  3. wumpz commented on Dec 3, 2026

    @wumpz
    Collaborator

    PRs are welcome

  4. wumpz commented on Dec 3, 2026

    @wumpz
    Collaborator

    I changed already the line. However, could you provide a proper test.

  5. reopened this on Dec 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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