Commit: patch 9.2.0887: scroll: jump-scrolling when moving the cursor onto a wrapping line

Christian Brabandt <[email protected]> Fri, 31 Jul 2026 21:15:04 +0200
Newsgroups gmane.editors.vim.devel
Message-ID <[email protected]>
patch 9.2.0887: scroll: jump-scrolling when moving the cursor onto a wrapping line

Commit: https://github.com/vim/vim/commit/d0b42a50b7da1cd443df02df45b1faf9c6691262
Author: Hirohito Higashi <[email protected]>
Date:   Fri Jul 31 18:58:18 2026 +0000

    patch 9.2.0887: scroll: jump-scrolling when moving the cursor onto a wrapping line
    
    Problem:  With 'smoothscroll' and "lastline" in 'display', moving the cursor
              to a wrapping line scrolls much more than needed.
    Solution: Only require the screen lines up to the cursor to be visible, the
              rest of the line can be cut off at the bottom.
    
    closes: #20895
    
    Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
    Signed-off-by: Hirohito Higashi <[email protected]>
    Signed-off-by: Christian Brabandt <[email protected]>

diff --git a/runtime/doc/todo.txt b/runtime/doc/todo.txt
index a8073702f..6329ac24a 100644
--- a/runtime/doc/todo.txt
+++ b/runtime/doc/todo.txt
@@ -64,9 +64,6 @@ Virtual text problems:
 When 'virtualedit' is "all" and 'cursorcolumn' is set, the wrong column may be
 highlighted. (van-de-bugger, 2018 Jan 23, #2576)
 
-With 'smoothscroll' set and "lastline" in 'display', moving the cursor to a
-wrapping line that makes the display scroll up may scroll much more than
-needed, thus jump-scrolling. (part of issue 12411)
 Errors when running tests with valgrind:
 - test_codestyle.vim:  e.g.:
     command line..script /home/mool/vim/vim91/src/testdir/runtest.vim[569]..function RunTheTest[52]..Test_test_files line 6: keycode_check.vim: space before tab: Expected 0 but got 7
diff --git a/src/move.c b/src/move.c
index cd9169de9..9b45b0e2b 100644
--- a/src/move.c
+++ b/src/move.c
@@ -2701,6 +2701,15 @@ scroll_cursor_bot(int min_scroll, int set_topbot)
     used = curwin->w_cline_height;
 #endif
 
+    if (do_sms && (dy_flags & DY_LASTLINE))
+    {
+	// The rest of the cursor line may be cut off at the bottom.
+	int upto_cursor = plines_win_col(curwin, cln, curwin->w_cursor.col);
+
+	if (upto_cursor < used)
+	    used = upto_cursor;
+    }
+
     // If the cursor is on or below botline, we will at least scroll by the
     // height of the cursor line, which is "used".  Correct for empty lines,
     // which are really part of botline.
diff --git a/src/testdir/test_scroll_opt.vim b/src/testdir/test_scroll_opt.vim
index fc266da03..ee865e637 100644
--- a/src/testdir/test_scroll_opt.vim
+++ b/src/testdir/test_scroll_opt.vim
@@ -1370,6 +1370,26 @@ func Test_smoothscroll_squeezed_window()
   bwipe!
 endfunc
 
+func Test_smoothscroll_lastline_no_jump()
+  call NewWindow(10, 40)
+  setlocal smoothscroll
+  set display=lastline
+  call setline(1, map(range(1, 9), {i, v -> 'short ' .. v})
+        \ + [repeat('long ', 60)] + repeat(['tail'], 5))
+  normal! gg
+  redraw
+  call assert_equal(1, line('w0'))
+
+  " The first screen line of the wrapping line is already visible.
+  normal! 9j
+  redraw
+  call assert_equal(10, line('.'))
+  call assert_equal(1, line('w0'))
+
+  set display&
+  bwipe!
+endfunc
+
 func Test_smoothscroll_long_line_zb()
   call NewWindow(10, 40)
   call setline(1, 'abcde '->repeat(150))
diff --git a/src/version.c b/src/version.c
index 59e9c7bb4..b3bd5174f 100644
--- a/src/version.c
+++ b/src/version.c
@@ -758,6 +758,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    887,
 /**/
     886,
 /**/

-- 
-- 
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/E1wpshE-006Gjn-Sn%40256bit.org.