Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep vertical position when go back #6524

Open
failable opened this issue Apr 1, 2023 · 1 comment
Open

Keep vertical position when go back #6524

failable opened this issue Apr 1, 2023 · 1 comment
Labels
A-command Area: Commands C-enhancement Category: Improvements

Comments

@failable
Copy link

failable commented Apr 1, 2023

The vertical position is not kept when going to definition then going back to last position. For example,

  1. z z on some line in file A.
  2. g d on some symbol to go into file B.
  3. ctrl-o go back the file A, the vertical position is changed to some bottom position. One may need to z z again.

After some tests, the vertical position when going back to file seems to be always different from the original position no matter where one starts to jump from.

@failable failable added the C-enhancement Category: Improvements label Apr 1, 2023
@Carrotstrip
Copy link
Contributor

Jump is defined as type Jump = (DocumentId, Selection), and Helix just tries to vertically center your selection on executing a jump. IMO this would be acceptable behavior if not for the fact that horizontal viewport offset is similarly naive, i.e if you save a location to the jumplist with Ctrl-s, then scroll the viewport off to the right on some long line, then hit Ctrl-o to jump back to your saved spot, the viewport won't jump back to its horizontal offset from when you saved the spot, because the jump simply does not remember where that was. We could either apply a similar transform horizontally as we do vertically (ensuring that the cursor is as centered as possible after the jump, right now we just ensure that it is in view) or add viewport position info to Jump so that we can return to exactly where we were when we saved the position. This then becomes another thing to update on any Transaction, so that the jumplist does not get out of sync with the the Document. The jumplist capacity was restricted a while ago by @the-mikedavis due to perf concerns, so I don't really have a sense for whether we can afford this, but the Helix jumplist is already much smaller than vim/nvim (30 vs 100), so we probably can? I like this change myself; I can get disoriented if the viewport moves from where I remember it being.

@kirawi kirawi added the A-command Area: Commands label Apr 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-command Area: Commands C-enhancement Category: Improvements
Projects
None yet
Development

No branches or pull requests

3 participants