summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuuk van Baal <luukvbaal@gmail.com>2023-05-06 12:40:15 +0100
committerBram Moolenaar <Bram@vim.org>2023-05-06 12:40:15 +0100
commitc8502f9b880b6d23baa4f9d28b60e1ceb442e35f (patch)
treee87ae73d24b972095f15d83fef32115361526e29
parent12e7a1fe7527e9e59adbe248a95b4b532e3ec58c (diff)
downloadvim-git-9.0.1512.tar.gz
patch 9.0.1512: inserting lines when scrolling with 'smoothscroll' setv9.0.1512
Problem: Inserting lines when scrolling with 'smoothscroll' set. Solution: Adjust line height computation for w_skipcol. (Luuk van Baal, closes #12350)
-rw-r--r--src/drawscreen.c10
-rw-r--r--src/move.c6
-rw-r--r--src/proto/move.pro1
-rw-r--r--src/testdir/dumps/Test_smooth_ins_lines.dump6
-rw-r--r--src/testdir/test_scroll_opt.vim27
-rw-r--r--src/version.c2
6 files changed, 46 insertions, 6 deletions
diff --git a/src/drawscreen.c b/src/drawscreen.c
index 13892bb7c..a07c176d0 100644
--- 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);
diff --git a/src/move.c b/src/move.c
index 77d8b5f85..54164a3f2 100644
--- 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 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.
diff --git a/src/proto/move.pro b/src/proto/move.pro
index 0858e26b0..1fe46a341 100644
--- 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);
diff --git a/src/testdir/dumps/Test_smooth_ins_lines.dump b/src/testdir/dumps/Test_smooth_ins_lines.dump
new file mode 100644
index 000000000..a0854529a
--- /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|
diff --git a/src/testdir/test_scroll_opt.vim b/src/testdir/test_scroll_opt.vim
index bab1e08fe..da1912796 100644
--- 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
diff --git a/src/version.c b/src/version.c
index 9f4a44934..08f213a10 100644
--- 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,