From 3e6cec0befd41d37ee36cb4f602e84c58c5f0d27 Mon Sep 17 00:00:00 2001 From: luukvbaal Date: Fri, 5 Jul 2024 01:51:34 +0200 Subject: vim-patch:9.1.0526: Unwanted cursor movement with pagescroll at start of buffer (#29569) Problem: Cursor is moved to bottom of window trying to pagescroll when already at the start of the buffer (Asheq Imran, after v9.1.0357) Solution: Don't move cursor when buffer content did not move. (Luuk van Baal) https://github.com/vim/vim/commit/8ccb89016e4b4b7f87acd1da78486c077350ceef --- src/nvim/move.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/nvim') diff --git a/src/nvim/move.c b/src/nvim/move.c index e942f58711..8c206b3e8d 100644 --- a/src/nvim/move.c +++ b/src/nvim/move.c @@ -2518,9 +2518,11 @@ int pagescroll(Direction dir, int count, bool half) ? MAX(1, (int)p_window - 2) : get_scroll_overlap(dir)); nochange = scroll_with_sms(dir, count, &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 (!nochange) { + // 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) { -- cgit