sublime_merge icon indicating copy to clipboard operation
sublime_merge copied to clipboard

Selected hunk is reset after staging a line

Open deathaxe opened this issue 1 year ago • 1 comments

Version info

  • OS: Windows 11
  • Build: 2095

Description

A workspace contains multiple hunks, each of which only a part of is to be staged by only using keyboard navigation.

Steps to reproduce

  1. Open a repository with multiple changes in worktree
  2. Open SM's Commit Dialog
  3. Navigate to any but the first diff hunk hitting tab key (multiple times)
  4. use cursor to select some text
  5. hit enter to stage the selected text's line
  6. hit tab key

Expected behavior

The next diff hunk is selected,
so all desired changes can be added by repeating steps 4 to 6.

Actual behavior

SM forgets its currently focused hunk and therefore focuses first one.

So if a line from hunk 1000 was staged, I now need to hit tab 1001 times to navigate to the next hunk of interest.

That's pretty inefficient.

deathaxe avatar Apr 28 '24 08:04 deathaxe

I came here to report the same bug, I made a video of the issue here: https://www.youtube.com/watch?v=cISOZ4TLNBE

It is even more severe than just being inefficient. When the focus is reset to the top of the file, you presumably skipped over that hunk because you didn't want to stage it. If you accidentally hit enter thinking that you wanted to stage the next hunk that is in your view but instead staged the first hunk that isn't even on the screen.

So now you have to find it inside the staging hunks to unstage it. That is if you knew about the issue, there is no visual confirmation that this has happened.

You could easily think that nothing happened, that the window lost keyboard focus after hitting enter a couple of times, and then use the mouse to stage the next hunk. Not knowing that you have hunks in your staging that you didn't intend—that you might then push.

Which could be destructive.

By the way I'm using an unlicensed version in the video—new machine, I'm lazy and like the light theme—but I do have a license:

image

Invoice 1021873.

nevarrik avatar Sep 01 '24 21:09 nevarrik

This issue occurs even when there is no selection and Enter is pressed to stage the entire hunk (i.e. skipping step 4 in the OP reproduction). So it's a downright fundamental issue.

frou avatar Jun 04 '25 17:06 frou