-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
File-scrolling by moving the cursor -> enable scrolling all the way to file ends #4590
Conversation
Does this mean that with this change, if I Ctrl+u and then Ctrl+d I'm back to the initial position (unless I hit the document start/end)? |
Simply put, yes. And not only with Ctrl+u/Ctrl+d. This change affects all methods of file scrolling, including mousewheel, Ctrl+b/Ctrl+f etc. It is the doc's view now that has to adjust itself around the cursor. I know that this means that, for example, if you wanted to peek under the cursor without moving the cursor it's now not possible. I could implement it so that the change has the same functionality as before and just detect when it has to make that final jump to the file edges, but the current implementation felt more natural to me. To be fair, I think that if the previous functionality is preferable we should stick with the previous implementation in general. I believe that scrolling the viewport(just like in previous version) and making the cursor jump to file edges(just like it is described in the issue) are orthogonal, because the latter implies controlling the cursor and not the view. It would not make sense to me to scoll the view all the way to the end of the file and suddenly have a cursor jump at the end. The other way we could do this is to implement just what neovim does. Stick the cursor to its relative position to the viewport no matter where that position is and scroll only the view until it hits the file bounds, where cursor movement takes over. |
Thanks for elaborating. I prefer this new behavior. |
Thank you! I will take that as a compliment |
I agree: the new behavior seems backwards to me. Scrolling should move the view and the cursor should only move if necessary to keep it in view. Being able to scroll so that we're on the last line should be possible though without changing this approach. In order to scroll to the last line, we should change this check: helix/helix-term/src/commands.rs Lines 1375 to 1381 in 46eb185
Currently it prevents scrolling after the last line is visible when scrolling forward. We can change the condition to so that we stop scrolling forward only when we're on the last line: With this change we will also need to switch the order of the helix/helix-term/src/commands.rs Lines 1397 to 1400 in 46eb185
let line = cursor
.row
.min(last_line.saturating_sub(scrolloff))
.max(view.offset.row + scrolloff); |
This PR has gone stale and this was actually implemented im #5420 |
This is an attempt to fix #4491. Previously, file scrolling was performed by scrolling the view of the doc and, then, repositioning the cursor accordingly. In this version, I implemented the opposite. Now, the cursor is the one moving the view. In other words, the view now clamps around the cursor based on the cursor's offset. The implementation still respects the
scolloff
setting.Not ready yet. It requires some further testing.
Note: I recommend building with --profile=opt. Otherwise, scrolling with the mousewheel is laggy even with the previous code's version.