]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0887: scroll: jump-scrolling when moving the cursor onto a wrapping line v9.2.0887
authorHirohito Higashi <h.east.727@gmail.com>
Fri, 31 Jul 2026 18:58:18 +0000 (18:58 +0000)
committerChristian Brabandt <cb@256bit.org>
Fri, 31 Jul 2026 18:58:18 +0000 (18:58 +0000)
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) <noreply@anthropic.com>
Signed-off-by: Hirohito Higashi <h.east.727@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
runtime/doc/todo.txt
src/move.c
src/testdir/test_scroll_opt.vim
src/version.c

index a8073702f13f2dde662f0ca10182cff2eb673ea3..6329ac24a6f6ac977a5f1b97c0dccffe439fdf67 100644 (file)
@@ -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
index cd9169de94a575a4eb5eaf6925c65f3801f5ef45..9b45b0e2bc9de62dfc14fefb586ffc3cfbbc3105 100644 (file)
@@ -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.
index fc266da03e852bbc071a0660b55c1bf443232790..ee865e6372a009df519cdd3bd1c8c81b004badfe 100644 (file)
@@ -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))
index 59e9c7bb4bd7bd3ed1cf099e77093e415aa8748c..b3bd5174f6c23eb7bedc98ddb3708a540998a205 100644 (file)
@@ -758,6 +758,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    887,
 /**/
     886,
 /**/