patch 9.2.0591: 'scrolljump' ignored when scrolling up

Commit: 
https://github.com/vim/vim/commit/a4a60c0fdb8aeec21dcd14871c465fe0f2e6fbc3
Author: glepnir <[email protected]>
Date:   Wed Jun 3 18:48:46 2026 +0000

    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 <[email protected]>
    Signed-off-by: Christian Brabandt <[email protected]>

diff --git a/src/move.c b/src/move.c
index 14271240f..ec5936b48 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 d9ca39634..4b7eea1b2 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 bc577f9ba..e2999b0b2 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,
 /**/

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/vim_dev/E1wUqou-003s4u-GQ%40256bit.org.

Raspunde prin e-mail lui