]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.1388: Scrolling one line too far with 'nosmoothscroll' page scrolling v9.1.1388
authorLuuk van Baal <luukvbaal@gmail.com>
Wed, 14 May 2025 18:21:55 +0000 (20:21 +0200)
committerChristian Brabandt <cb@256bit.org>
Wed, 14 May 2025 18:21:55 +0000 (20:21 +0200)
Problem:  One-off error in "count" to make "w_skipcol" zero with
          'nosmoothscroll' page scrolling when last virtual line
          in a buffer line is exactly the entire window width.
          (Hirohito Higashi)
Solution: Properly compute the smallest integer value necessary
          to make "w_skipcol" zero (Luuk van Baal)

fixes: #17317
closes: #17318

Signed-off-by: Luuk van Baal <luukvbaal@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
src/move.c
src/testdir/test_normal.vim
src/version.c

index 1c1eddeef5c01f50709f19564666d37b8bf6175e..e3771a5e2672ba6cada540ee384dd900f174eea1 100644 (file)
@@ -3215,10 +3215,10 @@ static int scroll_with_sms(int dir, long count, long *curscount)
 
        int width1 = curwin->w_width - curwin_col_off();
        int width2 = width1 + curwin_col_off2();
-       count = 1 + (curwin->w_skipcol - width1) / width2;
+       count = 1 + (curwin->w_skipcol - width1 - 1) / width2;
        if (fixdir == FORWARD)
-           count = 2 + (linetabsize_eol(curwin, curwin->w_topline)
-                                       - curwin->w_skipcol - width1) / width2;
+           count = 1 + (linetabsize_eol(curwin, curwin->w_topline)
+                           - curwin->w_skipcol - width1 + width2 - 1) / width2;
        scroll_redraw(fixdir == FORWARD, count);
        *curscount += count * (fixdir == dir ? 1 : -1);
     }
index 7f4f909645e5d41a64e0abef53a859eddd63fcdf..069651f6bcbabde322494b611f57ca50f0e40166 100644 (file)
@@ -4354,4 +4354,21 @@ func Test_scroll_longline_benchmark()
   bwipe!
 endfunc
 
+" Test Ctrl-B with 'nosmoothscroll' not stuck with line exactly window width.
+func Test_scroll_longline_winwidth()
+  10new
+  call setline(1, ['']->repeat(20) + ['A'->repeat(20 * winwidth(0))] + ['']->repeat(20))
+  exe "normal! G3\<C-B>"
+  call assert_equal(22, line('w0'))
+  exe "normal! \<C-B>"
+  call assert_equal(21, line('w0'))
+  exe "normal! \<C-B>"
+  call assert_equal(11, line('w0'))
+  exe "normal! \<C-B>"
+  call assert_equal(3, line('w0'))
+  exe "normal! \<C-B>"
+  call assert_equal(1, line('w0'))
+  bwipe!
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab nofoldenable
index 7e6e862de6817a8b499bcc5e86b30af5ce818049..89c9fb0f3f69f0a66ef896de1e741717962acc00 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1388,
 /**/
     1387,
 /**/