Skip to content

fix(macos): keep related diff removals and additions aligned #2247

Open

Description

@LHagfoss

Bug

The macOS inline diff can make a change look split or out of order. In the attached screenshot, a removed line appears after an unchanged context row, separated from the nearby additions. This makes it difficult to tell which old lines were replaced by which new lines.

The diff is still showing sequential file line numbers, but the visual matching/grouping around the hunk looks unintuitive. Please inspect the line-diff algorithm and its tie-breaking when multiple lines are repeated or similar, rather than only adjusting the gutter presentation.

Expected

Related removals and additions should appear together as a coherent changed block, with unchanged context retained where it helps explain the change. The old/new line mapping should remain correct.

Investigation

  • Reproduce from the edit shown in the attached screenshot (around lines 8937–8941).
  • Check whether the LCS matcher chooses an unhelpful context match and leaves a related removal stranded after it.
  • Add a focused test for the captured old/new text and adjust matching/tie-breaking if needed.

Platform

macOS

Activity

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions