summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-10-06 14:57:53 +0100
committerBram Moolenaar <Bram@vim.org>2022-10-06 14:57:53 +0100
commit9bab7a024393200bb2c03b3abddfda86436990a7 (patch)
treeb5a76b2251daed2bbd2ef703b0e61341d1582346
parent1a58e1d97cfc72e501cbf63ad75f46f1bb4c8da2 (diff)
downloadvim-git-9bab7a024393200bb2c03b3abddfda86436990a7.tar.gz
patch 9.0.0672: line partly shows with 'smoothscroll' and 'scrolloff' zerov9.0.0672
Problem: Cursor line only partly shows with 'smoothscroll' and 'scrolloff' zero. Solution: Do not use 'smoothscroll' when adjusting the bottom of the window. (closes #11269)
-rw-r--r--src/move.c10
-rw-r--r--src/testdir/dumps/Test_smooth_wrap_1.dump8
-rw-r--r--src/testdir/dumps/Test_smooth_wrap_2.dump8
-rw-r--r--src/testdir/dumps/Test_smooth_wrap_3.dump8
-rw-r--r--src/testdir/dumps/Test_smooth_wrap_4.dump8
-rw-r--r--src/testdir/test_scroll_opt.vim25
-rw-r--r--src/version.c2
7 files changed, 69 insertions, 0 deletions
diff --git a/src/move.c b/src/move.c
index e79ed726e..77f5cb92b 100644
--- a/src/move.c
+++ b/src/move.c
@@ -2171,6 +2171,7 @@ scroll_cursor_bot(int min_scroll, int set_topbot)
{
int used;
int scrolled = 0;
+ int min_scrolled = 1;
int extra = 0;
int i;
linenr_T line_count;
@@ -2236,6 +2237,10 @@ scroll_cursor_bot(int min_scroll, int set_topbot)
scrolled = used;
if (cln == curwin->w_botline)
scrolled -= curwin->w_empty_rows;
+ min_scrolled = scrolled;
+ if (cln > curwin->w_botline && curwin->w_p_sms && curwin->w_p_wrap)
+ for (linenr_T lnum = curwin->w_botline + 1; lnum <= cln; ++lnum)
+ min_scrolled += plines_nofill(lnum);
}
/*
@@ -2361,7 +2366,12 @@ scroll_cursor_bot(int min_scroll, int set_topbot)
if (line_count >= curwin->w_height && line_count > min_scroll)
scroll_cursor_halfway(FALSE);
else
+ {
+ // With 'smoothscroll' scroll at least the height of the cursor line.
+ if (curwin->w_p_wrap && curwin->w_p_sms && line_count < min_scrolled)
+ line_count = min_scrolled;
scrollup(line_count, TRUE);
+ }
/*
* If topline didn't change we need to restore w_botline and w_empty_rows
diff --git a/src/testdir/dumps/Test_smooth_wrap_1.dump b/src/testdir/dumps/Test_smooth_wrap_1.dump
new file mode 100644
index 000000000..0b52d40e5
--- /dev/null
+++ b/src/testdir/dumps/Test_smooth_wrap_1.dump
@@ -0,0 +1,8 @@
+|<+0#4040ff13#ffffff0@2|h+0#0000000&| |s|o|m|e| |t|e|x|t| |w|i|t|h| |s|o|m|e| |t|e|x|t| @10
+|L|i|n|e| |w|i|t|h| |s|o|m|e| |t|e|x|t| |w|i|t|h| |s|o|m|e| |t|e|x|t| |w|i|t|h|
+|s|o|m|e| |t|e|x|t| |w|i|t|h| |s|o|m|e| |t|e|x|t| |w|i|t|h| |s|o|m|e| |t|e|x|t|
+|w|i|t|h| |s|o|m|e| |t|e|x|t| |w|i|t|h| |s|o|m|e| |t|e|x|t| @10
+>L|i|n|e| |w|i|t|h| |s|o|m|e| |t|e|x|t| |w|i|t|h| |s|o|m|e| |t|e|x|t| |w|i|t|h|
+|s|o|m|e| |t|e|x|t| |w|i|t|h| |s|o|m|e| |t|e|x|t| |w|i|t|h| |s|o|m|e| |t|e|x|t|
+|w|i|t|h| |s|o|m|e| |t|e|x|t| |w|i|t|h| |s|o|m|e| |t|e|x|t| @10
+@22|3|,|1| @10|T|o|p|
diff --git a/src/testdir/dumps/Test_smooth_wrap_2.dump b/src/testdir/dumps/Test_smooth_wrap_2.dump
new file mode 100644
index 000000000..65a357dbb
--- /dev/null
+++ b/src/testdir/dumps/Test_smooth_wrap_2.dump
@@ -0,0 +1,8 @@
+|<+0#4040ff13#ffffff0@2|h+0#0000000&| |s|o|m|e| |t|e|x|t| |w|i|t|h| |s|o|m|e| |t|e|x|t| @10
+|L|i|n|e| |w|i|t|h| |s|o|m|e| |t|e|x|t| |w|i|t|h| |s|o|m|e| |t|e|x|t| |w|i|t|h|
+|s|o|m|e| |t|e|x|t| |w|i|t|h| |s|o|m|e| |t|e|x|t| |w|i|t|h| |s|o|m|e| |t|e|x|t|
+|w|i|t|h| |s|o|m|e| |t|e|x|t| |w|i|t|h| |s|o|m|e| |t|e|x|t| @10
+>L|i|n|e| |w|i|t|h| |s|o|m|e| |t|e|x|t| |w|i|t|h| |s|o|m|e| |t|e|x|t| |w|i|t|h|
+|s|o|m|e| |t|e|x|t| |w|i|t|h| |s|o|m|e| |t|e|x|t| |w|i|t|h| |s|o|m|e| |t|e|x|t|
+|w|i|t|h| |s|o|m|e| |t|e|x|t| |w|i|t|h| |s|o|m|e| |t|e|x|t| @10
+@22|4|,|1| @10|2|5|%|
diff --git a/src/testdir/dumps/Test_smooth_wrap_3.dump b/src/testdir/dumps/Test_smooth_wrap_3.dump
new file mode 100644
index 000000000..4bf5130fc
--- /dev/null
+++ b/src/testdir/dumps/Test_smooth_wrap_3.dump
@@ -0,0 +1,8 @@
+|<+0#4040ff13#ffffff0@2|h+0#0000000&| |s|o|m|e| |t|e|x|t| |w|i|t|h| |s|o|m|e| |t|e|x|t| @10
+|L|i|n|e| |w|i|t|h| |s|o|m|e| |t|e|x|t| |w|i|t|h| |s|o|m|e| |t|e|x|t| |w|i|t|h|
+|s|o|m|e| |t|e|x|t| |w|i|t|h| |s|o|m|e| |t|e|x|t| |w|i|t|h| |s|o|m|e| |t|e|x|t|
+|w|i|t|h| |s|o|m|e| |t|e|x|t| |w|i|t|h| |s|o|m|e| |t|e|x|t| @10
+>L|i|n|e| |w|i|t|h| |s|o|m|e| |t|e|x|t| |w|i|t|h| |s|o|m|e| |t|e|x|t| |w|i|t|h|
+|s|o|m|e| |t|e|x|t| |w|i|t|h| |s|o|m|e| |t|e|x|t| |w|i|t|h| |s|o|m|e| |t|e|x|t|
+|w|i|t|h| |s|o|m|e| |t|e|x|t| |w|i|t|h| |s|o|m|e| |t|e|x|t| @10
+@22|5|,|1| @10|5|0|%|
diff --git a/src/testdir/dumps/Test_smooth_wrap_4.dump b/src/testdir/dumps/Test_smooth_wrap_4.dump
new file mode 100644
index 000000000..c23f494dc
--- /dev/null
+++ b/src/testdir/dumps/Test_smooth_wrap_4.dump
@@ -0,0 +1,8 @@
+|<+0#4040ff13#ffffff0@2|h+0#0000000&| |s|o|m|e| |t|e|x|t| |w|i|t|h| |s|o|m|e| |t|e|x|t| @10
+|L|i|n|e| |w|i|t|h| |s|o|m|e| |t|e|x|t| |w|i|t|h| |s|o|m|e| |t|e|x|t| |w|i|t|h|
+|s|o|m|e| |t|e|x|t| |w|i|t|h| |s|o|m|e| |t|e|x|t| |w|i|t|h| |s|o|m|e| |t|e|x|t|
+|w|i|t|h| |s|o|m|e| |t|e|x|t| |w|i|t|h| |s|o|m|e| |t|e|x|t| @10
+>L|i|n|e| |w|i|t|h| |s|o|m|e| |t|e|x|t| |w|i|t|h| |s|o|m|e| |t|e|x|t| |w|i|t|h|
+|s|o|m|e| |t|e|x|t| |w|i|t|h| |s|o|m|e| |t|e|x|t| |w|i|t|h| |s|o|m|e| |t|e|x|t|
+|w|i|t|h| |s|o|m|e| |t|e|x|t| |w|i|t|h| |s|o|m|e| |t|e|x|t| @10
+@22|7|,|1| @10|B|o|t|
diff --git a/src/testdir/test_scroll_opt.vim b/src/testdir/test_scroll_opt.vim
index b114fe360..d11d0be0f 100644
--- a/src/testdir/test_scroll_opt.vim
+++ b/src/testdir/test_scroll_opt.vim
@@ -167,6 +167,31 @@ func Test_smoothscroll_diff_mode()
call StopVimInTerminal(buf)
endfunc
+func Test_smoothscroll_wrap_scrolloff_zero()
+ CheckScreendump
+
+ let lines =<< trim END
+ vim9script
+ setline(1, ['Line' .. (' with some text'->repeat(7))]->repeat(7))
+ set smoothscroll scrolloff=0
+ :3
+ END
+ call writefile(lines, 'XSmoothWrap', 'D')
+ let buf = RunVimInTerminal('-S XSmoothWrap', #{rows: 8, cols: 40})
+
+ call VerifyScreenDump(buf, 'Test_smooth_wrap_1', {})
+
+ call term_sendkeys(buf, "j")
+ call VerifyScreenDump(buf, 'Test_smooth_wrap_2', {})
+
+ call term_sendkeys(buf, "\<C-E>j")
+ call VerifyScreenDump(buf, 'Test_smooth_wrap_3', {})
+
+ call term_sendkeys(buf, "G")
+ call VerifyScreenDump(buf, 'Test_smooth_wrap_4', {})
+
+ call StopVimInTerminal(buf)
+endfunc
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/version.c b/src/version.c
index 5ddf40bab..4d8b40f9b 100644
--- a/src/version.c
+++ b/src/version.c
@@ -700,6 +700,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 672,
+/**/
671,
/**/
670,