]> granicus.if.org Git - vim/commitdiff
patch 9.0.1000: with 'smoothscroll' skipcol may be reset unnecessarily v9.0.1000
authorBram Moolenaar <Bram@vim.org>
Sat, 3 Dec 2022 18:35:07 +0000 (18:35 +0000)
committerBram Moolenaar <Bram@vim.org>
Sat, 3 Dec 2022 18:35:07 +0000 (18:35 +0000)
Problem:    With 'smoothscroll' skipcol may be reset unnecessarily.
Solution:   Check the line does actually fit in the window.

src/move.c
src/testdir/dumps/Test_smooth_long_9.dump
src/testdir/test_scroll_opt.vim
src/version.c

index d976697ec95e3f123cd419e7af214ec158cfd809..7a9ae3ea60d4319ba3564877d1ccd9913f1a9016 100644 (file)
@@ -1909,7 +1909,11 @@ adjust_skipcol(void)
     int            scrolled = FALSE;
 
     validate_cheight();
-    if (curwin->w_cline_height == curwin->w_height)
+    if (curwin->w_cline_height == curwin->w_height
+           // w_cline_height may be capped at w_height, check there aren't
+           // actually more lines.
+           && plines_win(curwin, curwin->w_cursor.lnum, FALSE)
+                                                          <= curwin->w_height)
     {
        // the line just fits in the window, don't scroll
        reset_skipcol();
index 8365ecc0a8cdc12c25d00626a0dc6ad8c74a3623..f4687be513771bebbd9cca41da38d3cde953de44 100644 (file)
@@ -1,6 +1,6 @@
-|<+0#4040ff13#ffffff0@2|o+0#0000000&|t|s| |o|f| |t|e|x|t| |w|i|t|h| |l|o|t|s| |o|f| |t|e|x|t| |w|i|t|h| |l|o
-|t|s| |o|f| |t|e|x|t| |w|i|t|h| |l|o|t|s| |o|f| |t|e|x|t| |w|i|t|h| |l|o|t|s| |o
-|f| |t|e|x|t| |w|i>t|h| |l|o|t|s| |o|f| |t|e|x|t| |w|i|t|h| |l|o|t|s| |o|f| |t|e
+|<+0#4040ff13#ffffff0@2|t+0#0000000&|h| |l|o|t|s| |o|f| |t|e|x|t| |w|i|t|h| |l|o|t|s| |o|f| |t|e|x|t| |w|i|t
+|h| |l|o|t|s| |o|f| |t|e|x|t| |w|i|t|h| |l|o|t|s| |o|f| |t|e|x|t| |w|i|t|h| |l|o
+|t|s| |o|f| |t|e|x>t| |w|i|t|h| |l|o|t|s| |o|f| |t|e|x|t| |w|i|t|h| |l|o|t|s| |o
+|f| |t|e|x|t| |w|i|t|h| |l|o|t|s| |o|f| |t|e|x|t| |w|i|t|h| |l|o|t|s| |o|f| |t|e
 |x|t| |w|i|t|h| |l|o|t|s| |o|f| |t|e|x|t| |w|i|t|h| |l|o|t|s| |o|f| |t|e|x|t| |w
-|i|t|h| |l|o|t|s| |o|f| |t|e|x|t| |w|i|t|h| |l|o|t|s| |o|f| |t|e|x|t| |w|i|t|h| 
-@22|3|,|1|7|0| @8|6@1|%| 
+|:|s|e|t| |s|c|r|o|l@1|o| @9|3|,|1|3|0| @8|6@1|%| 
index 6f8693ba7378ad63b72ed623c32891994a7adaf0..58a8bf4f9ec1b002719e95c72e696d1b9e6b05b6 100644 (file)
@@ -481,6 +481,13 @@ func Test_smoothscroll_cursor_scrolloff()
   exe "normal 20h"
   call s:check_col_calc(1, 4, 61)
 
+  " cursor on last line, "gk" should not cause a scroll
+  set scrolloff=0
+  normal G0
+  call s:check_col_calc(1, 7, 1)
+  normal gk
+  call s:check_col_calc(1, 6, 101)
+
   bwipe!
 endfunc
 
index b3a8ba4ebf31f03673d42936c5cf70d5978c6e63..10db2470806acd81add143bd4652e4c21e296da1 100644 (file)
@@ -695,6 +695,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1000,
 /**/
     999,
 /**/