Merge pull request #29570 from neovim/backport-29569-to-release-0.10

vim-patch:9.1.0526: Unwanted cursor movement with pagescroll at start of buffer
This commit is contained in:
zeertzjq 2024-07-05 08:14:39 +08:00 committed by GitHub
commit 5cad641848
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 3 deletions

View File

@ -2520,9 +2520,11 @@ int pagescroll(Direction dir, int count, bool half)
? MAX(1, (int)p_window - 2) : get_scroll_overlap(dir)); ? MAX(1, (int)p_window - 2) : get_scroll_overlap(dir));
nochange = scroll_with_sms(dir, count, &count); nochange = scroll_with_sms(dir, count, &count);
// Place cursor at top or bottom of window. if (!nochange) {
validate_botline(curwin); // Place cursor at top or bottom of window.
curwin->w_cursor.lnum = (dir == FORWARD ? curwin->w_topline : curwin->w_botline - 1); validate_botline(curwin);
curwin->w_cursor.lnum = (dir == FORWARD ? curwin->w_topline : curwin->w_botline - 1);
}
} }
if (get_scrolloff_value(curwin) > 0) { if (get_scrolloff_value(curwin) > 0) {

View File

@ -4267,6 +4267,9 @@ func Test_page_cursor_topbot()
call assert_equal(18, line('.')) call assert_equal(18, line('.'))
exe "norm! \<C-B>\<C-F>" exe "norm! \<C-B>\<C-F>"
call assert_equal(9, line('.')) call assert_equal(9, line('.'))
" Not when already at the start of the buffer.
exe "norm! ggj\<C-B>"
call assert_equal(2, line('.'))
bwipe! bwipe!
endfunc endfunc