aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorluukvbaal <luukvbaal@gmail.com>2024-04-22 15:24:32 +0200
committerGitHub <noreply@github.com>2024-04-22 21:24:32 +0800
commitea1c9f60e04429e8472370b59616d069ad7fbc8c (patch)
tree29c08d6e52d907acc96dd548bbb8302153a535c3 /src
parent783b0aba411618c27cae48625f0f98e0cb503758 (diff)
downloadrneovim-ea1c9f60e04429e8472370b59616d069ad7fbc8c.tar.gz
rneovim-ea1c9f60e04429e8472370b59616d069ad7fbc8c.tar.bz2
rneovim-ea1c9f60e04429e8472370b59616d069ad7fbc8c.zip
vim-patch:9.1.0357: Page scrolling should place cursor at window boundaries (#28429)
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) https://github.com/vim/vim/commit/4b6b0c4024df08dd8ce49dff3c76356ff81190c4
Diffstat (limited to 'src')
-rw-r--r--src/nvim/move.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/nvim/move.c b/src/nvim/move.c
index 3615959a02..459841827d 100644
--- a/src/nvim/move.c
+++ b/src/nvim/move.c
@@ -2492,23 +2492,27 @@ int pagescroll(Direction dir, int count, bool half)
} else {
cursor_up_inner(curwin, curscount);
}
-
- if (get_scrolloff_value(curwin) > 0) {
- cursor_correct(curwin);
- }
- // Move cursor to first line of closed fold.
- foldAdjustCursor(curwin);
-
- nochange = nochange
- && prev_col == curwin->w_cursor.col
- && prev_lnum == curwin->w_cursor.lnum;
} else {
// Scroll [count] times 'window' or current window height lines.
count *= ((ONE_WINDOW && p_window > 0 && p_window < Rows - 1)
? MAX(1, (int)p_window - 2) : get_scroll_overlap(dir));
nochange = scroll_with_sms(dir, count);
+
+ // Place cursor at top or bottom of window.
+ validate_botline(curwin);
+ curwin->w_cursor.lnum = (dir == FORWARD ? curwin->w_topline : curwin->w_botline - 1);
}
+ if (get_scrolloff_value(curwin) > 0) {
+ cursor_correct(curwin);
+ }
+ // Move cursor to first line of closed fold.
+ foldAdjustCursor(curwin);
+
+ 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();