]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.0.1512: inserting lines when scrolling with 'smoothscroll' set v9.0.1512
authorLuuk van Baal <luukvbaal@gmail.com>
Sat, 6 May 2023 11:40:15 +0000 (12:40 +0100)
committerBram Moolenaar <Bram@vim.org>
Sat, 6 May 2023 11:40:15 +0000 (12:40 +0100)
Problem:    Inserting lines when scrolling with 'smoothscroll' set.
Solution:   Adjust line height computation for w_skipcol. (Luuk van Baal,
            closes #12350)

src/drawscreen.c
src/move.c
src/proto/move.pro
src/testdir/dumps/Test_smooth_ins_lines.dump [new file with mode: 0644]
src/testdir/test_scroll_opt.vim
src/version.c

index 13892bb7ca20a604ed9f721ffca6215aca33cc76..a07c176d03407e7ea3a247b0cc7aea716d949c41 100644 (file)
@@ -2327,8 +2327,14 @@ win_update(win_T *wp)
                        {
 #ifdef FEAT_DIFF
                            if (l == wp->w_topline)
-                               new_rows += plines_win_nofill(wp, l, TRUE)
-                                                             + wp->w_topfill;
+                           {
+                               int n = plines_win_nofill(wp, l, FALSE)
+                                                               + wp->w_topfill;
+                               n = adjust_plines_for_skipcol(wp, n);
+                               if (n > wp->w_height)
+                                   n = wp->w_height;
+                               new_rows += n;
+                           }
                            else
 #endif
                                new_rows += plines_win(wp, l, TRUE);
index 77d8b5f85d536f8a174d6e12079b58cbb5258963..54164a3f24eca2999b890657c366cc7656ee821c 100644 (file)
@@ -38,7 +38,7 @@ static void botline_forw(lineoff_T *lp);
 /*
  * Reduce "n" for the screen lines skipped with "wp->w_skipcol".
  */
-    static int
+    int
 adjust_plines_for_skipcol(win_T *wp, int n)
 {
     if (wp->w_skipcol == 0)
@@ -239,7 +239,7 @@ skipcol_from_plines(win_T *wp, int plines_off)
 }
 
 /*
- * Set curwin->s_skipcol to zero and redraw later if needed.
+ * Set curwin->w_skipcol to zero and redraw later if needed.
  */
     static void
 reset_skipcol(void)
@@ -2990,7 +2990,7 @@ cursor_correct(void)
 
     if (curwin->w_p_sms && !curwin->w_p_wrap)
     {
-       // 'smoothscroll is active
+       // 'smoothscroll' is active
        if (curwin->w_cline_height == curwin->w_height)
        {
            // The cursor line just fits in the window, don't scroll.
index 0858e26b0d4a566d6d8a43bc5d58d99371f39f6c..1fe46a34105a46fd24ad73c53f4da8185d3a8233 100644 (file)
@@ -1,4 +1,5 @@
 /* move.c */
+int adjust_plines_for_skipcol(win_T *wp, int n);
 void redraw_for_cursorline(win_T *wp);
 void update_topline_redraw(void);
 void update_topline(void);
diff --git a/src/testdir/dumps/Test_smooth_ins_lines.dump b/src/testdir/dumps/Test_smooth_ins_lines.dump
new file mode 100644 (file)
index 0000000..a085452
--- /dev/null
@@ -0,0 +1,6 @@
+|<+0#4040ff13#ffffff0@2|l+0#0000000&|o|t|s| |o|f| |t|e|x|t| |i|n| |o|n|e| |l|i|n|e> @12
+|l|i|n|e| |t|w|o| @31
+|l|i|n|e| |t|h|r|e@1| @29
+|l|i|n|e| |f|o|u|r| @30
+|l|i|n|e| |f|i|v|e| @30
+@22|1|,|6|8| @9|A|l@1| 
index bab1e08fe8463b9891fbc7ffc1e8e034ad2b988c..da1912796bc1373dd7a55e25f0978cf646d909cf 100644 (file)
@@ -587,7 +587,7 @@ func Test_smoothscroll_mouse_pos()
 endfunc
 
 " this was dividing by zero
-func Test_smoothscrol_zero_width()
+func Test_smoothscroll_zero_width()
   CheckScreendump
 
   let lines =<< trim END
@@ -613,5 +613,30 @@ func Test_smoothscrol_zero_width()
   call StopVimInTerminal(buf)
 endfunc
 
+" this was unnecessarily inserting lines
+func Test_smoothscroll_ins_lines()
+  CheckScreendump
+
+  let lines =<< trim END
+      set wrap
+      set smoothscroll
+      set scrolloff=0
+      set conceallevel=2
+      call setline(1, [
+        \'line one' .. 'with lots of text in one line '->repeat(2),
+        \'line two',
+        \'line three',
+        \'line four',
+        \'line five'
+      \])
+  END
+  call writefile(lines, 'XSmoothScrollInsLines', 'D')
+  let buf = RunVimInTerminal('-S XSmoothScrollInsLines', #{rows: 6, cols: 40})
+
+  call term_sendkeys(buf, "\<C-E>gjgk")
+  call VerifyScreenDump(buf, 'Test_smooth_ins_lines', {})
+
+  call StopVimInTerminal(buf)
+endfunc
 
 " vim: shiftwidth=2 sts=2 expandtab
index 9f4a4493400fadda01e5d37b191be35eaeedf6c1..08f213a10497674b732b0da49a9966b8de467668 100644 (file)
@@ -695,6 +695,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1512,
 /**/
     1511,
 /**/