]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0591: 'scrolljump' ignored when scrolling up v9.2.0591
authorglepnir <glephunter@gmail.com>
Wed, 3 Jun 2026 18:48:46 +0000 (18:48 +0000)
committerChristian Brabandt <cb@256bit.org>
Wed, 3 Jun 2026 18:48:46 +0000 (18:48 +0000)
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 <glephunter@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/move.c
src/testdir/test_options.vim
src/version.c

index 14271240fd72b3220f1883f5bab48bf4602afa72..ec5936b48990734412b65ca253042a98d2e2f299 100644 (file)
@@ -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;
            }
        }
 
index d9ca39634a71392fbf7719feeb62486907d43850..4b7eea1b2f8aee981e5416ba5dbded29de82d7e6 100644 (file)
@@ -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
index bc577f9ba0deeb96ae4b42bf4d19281a9f1e2abc..e2999b0b230c3016bc7de389bf6a278e10505f2c 100644 (file)
@@ -729,6 +729,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    591,
 /**/
     590,
 /**/