Skip to content

Conversation

@sina-hide
Copy link
Contributor

If the last line is deleted or added, it was impossible to stage, unstage or discard the last hunk in a two-side diff view, if the hunk was selected on the side where the last line is missing (that's the left side for added lines and the right side for deleted lines).

Since the button(s) for hunk operations are on the right side of the diff view, it was easier to trigger this bug for a deleted last line.

This bug was introduced in commit 6511d15 while rewriting the text diff views.

This fixes the bug mentioned in #1950 (comment).

If the last line is deleted or added, it was impossible to stage,
unstage or discard the last hunk in a two-side diff view, if the hunk
was selected on the side where the last line is missing (that's the left
side for added lines and the right side for deleted lines).

Since the button(s) for hunk operations are on the right side of the
diff view, it was easier to trigger this bug for a deleted last line.

This bug was introduced in commit 6511d15 while rewriting the text
diff views.

This fixes the bug mentioned in
sourcegit-scm#1950 (comment).
@love-linger
Copy link
Collaborator

love-linger commented Jan 5, 2026

  • This code is very hard to read.
  • Since the New side always has the same line with Old side for modified lines, the sourceIndices[New.Count] will always override the sourceIndices[Old.Count]

And this issue does not exists when trying to stage/discard/unstage with selected contents (not auto-detected hunk) in one side.

I'll push my commit to fix this issue

love-linger added a commit that referenced this pull request Jan 5, 2026
@love-linger love-linger self-assigned this Jan 5, 2026
@love-linger love-linger closed this Jan 5, 2026
@sina-hide sina-hide deleted the two-side-regression branch January 5, 2026 06:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants