diff options
author | Luuk van Baal <luukvbaal@gmail.com> | 2024-04-20 17:38:20 +0200 |
---|---|---|
committer | Christian Brabandt <cb@256bit.org> | 2024-04-20 17:38:20 +0200 |
commit | 4b6b0c4024df08dd8ce49dff3c76356ff81190c4 (patch) | |
tree | a82401e59205b519fe1c078a0d2f99ebaa88f480 /src/move.c | |
parent | 59356019eb98b02caf086a26402307c5518e9f3a (diff) |
patch 9.1.0357: Page scrolling should place cursor at window boundariesv9.1.0357
Problem: Page scrolling does not always place the cursor at the top or
bottom of the window (Mathias Rav)
Solution: Place the cursor at the top or bottom of the window.
(Luuk van Baal)
fixes: #14585
closes: #14586
Signed-off-by: Luuk van Baal <luukvbaal@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Diffstat (limited to 'src/move.c')
-rw-r--r-- | src/move.c | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/src/move.c b/src/move.c index a234fca1d2..1b6e003cc0 100644 --- a/src/move.c +++ b/src/move.c @@ -3244,17 +3244,6 @@ pagescroll(int dir, long count, int half) cursor_down_inner(curwin, curscount); else cursor_up_inner(curwin, curscount); - - if (get_scrolloff_value() > 0) - cursor_correct(); -#ifdef FEAT_FOLDING - // Move cursor to first line of closed fold. - foldAdjustCursor(); -#endif - - nochange = nochange - && prev_col == curwin->w_cursor.col - && prev_lnum == curwin->w_cursor.lnum; } else { @@ -3262,8 +3251,23 @@ pagescroll(int dir, long count, int half) count *= ((ONE_WINDOW && p_window > 0 && p_window < Rows - 1) ? MAX(1, p_window - 2) : get_scroll_overlap(dir)); nochange = scroll_with_sms(dir, count); + + // Place cursor at top or bottom of window. + validate_botline(); + curwin->w_cursor.lnum = (dir == FORWARD ? curwin->w_topline + : curwin->w_botline - 1); } + if (get_scrolloff_value() > 0) + cursor_correct(); +#ifdef FEAT_FOLDING + // Move cursor to first line of closed fold. + foldAdjustCursor(); +#endif + nochange = nochange + && prev_col == curwin->w_cursor.col + && prev_lnum == curwin->w_cursor.lnum; + // Error if both the viewport and cursor did not change. if (nochange) beep_flush(); |