-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
implement nano-like page up/page down functionality #3518
Conversation
Hi guys, as discussed, this one modifies the
|
93d5a2e
to
0a78e53
Compare
Tried it and overall it seems to perform well.
The same happens in the reverse direction when you place the cursor in the last line or the line before, do a Looks again like a side effect of considering |
The only way to avoid this would be to check if the cursor is within the If we implement this, I think this logic should probably be in the |
This logic is already implemented in I.e. the problem can be fixed by not removing |
466bd72
to
b56e2b3
Compare
Like I said before, I think we should change the behavior of If it turns out that some users actually prefer the existing behavior and complain about the change, we can revert it and add new actions instead, at least knowing that it makes sense to do so.
Like I said before, I'm not sure reusing I'd prefer just to hardcode the overlap to be 1 or 2 lines for now, for simplicity. Or, if we insist on making it configurable right away, add a new option. |
Also what about |
b56e2b3
to
6ac4b1f
Compare
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Due to the usage of h.Relocate()
we still have a dependency to scrollmargin
:
- place the cursor in the first line
- perform
CursorPageDown()
-> The cursor will be placed toscrollmargin
and doesn't stay at the first line...and vice versa withCursorPageUp()
So what if the user likes to keep the cursor where he placed it...like in nano
?
Should we extract the content of Relocate()
into a separate function to control this behavior?
e.g.:
func (w *BufWindow) Relocate() bool {
return w.RelocateWithMargin(int(b.Settings["scrollmargin"].(float64))
}
func (w *BufWindow) RelocateWithMargin(scrollmargin int) bool {
[...]
}
func (h *BufPane) CursorPageDown() bool {
[...]
h.RelocateWithMargin(0)
[...]
}
But isn't that the purpose of |
6ac4b1f
to
b1b619e
Compare
Hm, arguable. Maybe we can use it for this scenario too. |
I guess we could get fancy and check the direction the user is moving the cursor, and relocate the view only if the cursor is being moved into scrollmargin. For instance, if we have a view height of 100 lines, scrollmargin of 5, and the cursor is on line 7. The user moves the cursor up with the up arrow, 7, 6, 5, and on the next keypress we relocate the view because we're moving inwards into the scrollmargin. But if the cursor is already inside the scrollmargin, say line 3, and the user goes to line 4, we're moving outwards from inside the scrollmargin, so we don't relocate. The downside would be that it wouldn't match other editors, could be confusing, and could give rise to interesting edge cases. |
As of now I'd say this fancy idea will make the things a bit too complicated. @dmaluka: |
I agree with @nimishjha that we should keep it simple and just respect BTW vim also has a |
2a13a33
to
35d2ca2
Compare
35d2ca2
to
5880c4a
Compare
5880c4a
to
b2dbcb3
Compare
Modifies the
CursorPageUp
andCursorPageDown
actions to behave like nano. Adds a new configuration setting,pageoverlap
. Both actions now scroll the view by (view height - pageoverlap) and keep the cursor at the same relative position in the view. Resolves #1808.