From: glepnir Date: Wed, 3 Jun 2026 18:48:46 +0000 (+0000) Subject: patch 9.2.0591: 'scrolljump' ignored when scrolling up X-Git-Tag: v9.2.0591^0 X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=a4a60c0fdb8aeec21dcd14871c465fe0f2e6fbc3;p=thirdparty%2Fvim.git patch 9.2.0591: 'scrolljump' ignored when scrolling up Problem: srolljump=-100 only scrolls half a page going up, but works fine going down. update_topline() always falls back to scroll_cursor_halfway() when the cursor is far above topline. Solution: Only center when sj is smaller than half the window. Otherwise call scroll_cursor_top like the downward path does (glepnir). fixes: #1527 closes: #20366 Signed-off-by: glepnir Signed-off-by: Christian Brabandt --- diff --git a/src/move.c b/src/move.c index 14271240fd..ec5936b489 100644 --- a/src/move.c +++ b/src/move.c @@ -431,22 +431,15 @@ update_topline(void) // If we weren't very close to begin with, we scroll to put the // cursor in the middle of the window. Otherwise put the cursor // near the top of the window. - if (n >= halfheight) - { - if (eof_pressure) - scroll_cursor_halfway(TRUE, TRUE); - else - scroll_cursor_halfway(FALSE, FALSE); - } + int min_scroll = scrolljump_value(); + if (eof_pressure) + scroll_cursor_halfway(TRUE, TRUE); + else if (n >= halfheight && min_scroll < halfheight) + scroll_cursor_halfway(FALSE, FALSE); else { - if (eof_pressure) - scroll_cursor_halfway(TRUE, TRUE); - else - { - scroll_cursor_top(scrolljump_value(), FALSE); - check_botline = TRUE; - } + scroll_cursor_top(min_scroll, FALSE); + check_botline = TRUE; } } diff --git a/src/testdir/test_options.vim b/src/testdir/test_options.vim index d9ca39634a..4b7eea1b2f 100644 --- a/src/testdir/test_options.vim +++ b/src/testdir/test_options.vim @@ -2472,6 +2472,13 @@ func Test_opt_scrolljump() \ 'topline':5, 'coladd':0, 'skipcol':0, 'curswant':0}, \ winsaveview()) + norm! 100Gzt + set scrolljump=-100 + norm! 20k + call assert_equal({'lnum':80, 'leftcol':0, 'col':0, 'topfill':0, + \ 'topline':71, 'coladd':0, 'skipcol':0, 'curswant':0}, + \ winsaveview()) + set scrolljump& bw endfunc diff --git a/src/version.c b/src/version.c index bc577f9ba0..e2999b0b23 100644 --- a/src/version.c +++ b/src/version.c @@ -729,6 +729,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 591, /**/ 590, /**/