Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Movement of point when staging is unnatural #366

Closed
purcell opened this Issue · 3 comments

3 participants

Steve Purcell Miles Bader Jonas Bernoulli
Steve Purcell

This is a usability feature request; given some feedback and pointers, I'd be happy to investigate implementing it myself.

A common part of my workflow (and presumably that of most users) is reviewing and then staging changes directly from the magit-status buffer.

After staging a hunk, I'd expect the point to move to the next pending hunk, but instead it stays on the same visual line, which may or may not correspond to the next hunk. Similarly, after staging the last hunk in a file, I'd expect the point to move to the next file in the list, but once again it stays on the same visual line, often several files further down the "Changes" list -- active keyboard or mouse navigation is required to return the cursor to the next file.

This makes it unnatural to systematically work through a set of changes, and it's pretty much the only pain point I have with magit in intensive daily use.

-Steve

Miles Bader

Yeah, I agree with this comment—although I think currently it often does the right thing by accident, I've had many experiences where I got completely confused after hitting "s" because it seemed to end up somewhere completely random... I've gotten in the habit of always being sure to mentally note the next item before hitting "s", but really, the computer should be doing this, not me... :)

I suppose the right thing to do is: the "s" command should identify the next section (where point would move if you hit "n") before staging, save a reference to that section, and then move there explicitly after staging.

Steve Purcell

I guess it doesn't apply to staging alone -- killing hunks one by one should work the same way. So perhaps there's a way for all the section-oriented commands to check after their completion whether the section is still there, and if not, move point to the next at the same level.

The magit source is quite highly abstracted at this point, so I'm hoping one of the regular committers will tell me where to look.

Jonas Bernoulli tarsius was assigned
Noam Postavsky npostavs referenced this issue from a commit in npostavs/magit
Noam Postavsky npostavs after a section is removed, move to next section
After (un)staging a hunk, the current section is removed, so the path
from magit-section-path which uses section names is no use finding the
old spot; magit-refresh-buffer then falls backs to line number which is
confusing, as described in #366.

Instead we build a path based on numeric indices instead of names to
move to the following section. After a section n is removed, section n+1
becomes the new section n so the saved numeric path brings us to the
right place.

The new functions magit-section-numpath and magit-find-section-by-num
build the path and follow it, respectively.
7d76c47
Jonas Bernoulli tarsius added original sin and removed 00 bug labels
Jonas Bernoulli tarsius modified the milestone: 2.1.0, better sections
Jonas Bernoulli
Owner

Closing in favor of #1322.

Jonas Bernoulli tarsius closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.