changeset 32361:9ac987a467d5 v9.0.1512

patch 9.0.1512: inserting lines when scrolling with 'smoothscroll' set Commit: https://github.com/vim/vim/commit/c8502f9b880b6d23baa4f9d28b60e1ceb442e35f Author: Luuk van Baal <luukvbaal@gmail.com> Date: Sat May 6 12:40:15 2023 +0100 patch 9.0.1512: inserting lines when scrolling with 'smoothscroll' set Problem: Inserting lines when scrolling with 'smoothscroll' set. Solution: Adjust line height computation for w_skipcol. (Luuk van Baal, closes #12350)
author Bram Moolenaar <Bram@vim.org>
date Sat, 06 May 2023 13:45:04 +0200
parents d0c44a70b750
children ab5eff34fb12
files src/drawscreen.c src/move.c src/proto/move.pro src/testdir/dumps/Test_smooth_ins_lines.dump src/testdir/test_scroll_opt.vim src/version.c
diffstat 6 files changed, 46 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/drawscreen.c
+++ b/src/drawscreen.c
@@ -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);
--- a/src/move.c
+++ b/src/move.c
@@ -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 pline
 }
 
 /*
- * 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.
--- a/src/proto/move.pro
+++ b/src/proto/move.pro
@@ -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);
new file mode 100644
--- /dev/null
+++ b/src/testdir/dumps/Test_smooth_ins_lines.dump
@@ -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| 
--- a/src/testdir/test_scroll_opt.vim
+++ b/src/testdir/test_scroll_opt.vim
@@ -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
--- a/src/version.c
+++ b/src/version.c
@@ -696,6 +696,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    1512,
+/**/
     1511,
 /**/
     1510,