summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuuk van Baal <luukvbaal@gmail.com>2023-05-19 14:04:47 +0100
committerBram Moolenaar <Bram@vim.org>2023-05-19 14:04:47 +0100
commitd49f646bf56b29d44bbb16e79bc877b59aab38ac (patch)
tree7c7ca1962a802376fdb34bc55b58b7c687753394
parentd13c254d100509271b37d609c19e45c857352181 (diff)
patch 9.0.1568: with 'smoothscroll' cursor may move below botlinev9.0.1568
Problem: With 'smoothscroll' cursor may move below botline. Solution: Call redraw_later() if needed, Compute cursor row with adjusted condition. (Luuk van Baal, closes #12415)
-rw-r--r--src/move.c7
-rw-r--r--src/testdir/dumps/Test_smooth_incsearch_1.dump8
-rw-r--r--src/testdir/dumps/Test_smooth_incsearch_2.dump8
-rw-r--r--src/testdir/dumps/Test_smooth_incsearch_3.dump8
-rw-r--r--src/testdir/dumps/Test_smooth_incsearch_4.dump8
-rw-r--r--src/testdir/dumps/Test_smooth_wrap_2.dump6
-rw-r--r--src/testdir/dumps/Test_smooth_wrap_4.dump4
-rw-r--r--src/testdir/test_scroll_opt.vim33
-rw-r--r--src/version.c2
9 files changed, 75 insertions, 9 deletions
diff --git a/src/move.c b/src/move.c
index 3f6802ac7f..e435bb08bb 100644
--- a/src/move.c
+++ b/src/move.c
@@ -519,6 +519,8 @@ update_topline(void)
// When 'smoothscroll' is not set, should reset w_skipcol.
if (!curwin->w_p_sms)
reset_skipcol();
+ else if (curwin->w_skipcol != 0)
+ redraw_later(UPD_SOME_VALID);
// May need to set w_skipcol when cursor in w_topline.
if (curwin->w_cursor.lnum == curwin->w_topline)
@@ -892,10 +894,11 @@ curs_rows(win_T *wp)
--i; // hold at inserted lines
}
if (valid
+ && (lnum != wp->w_topline || (wp->w_skipcol == 0
#ifdef FEAT_DIFF
- && (lnum != wp->w_topline || !wp->w_p_diff)
+ && !wp->w_p_diff
#endif
- )
+ )))
{
#ifdef FEAT_FOLDING
lnum = wp->w_lines[i].wl_lastlnum + 1;
diff --git a/src/testdir/dumps/Test_smooth_incsearch_1.dump b/src/testdir/dumps/Test_smooth_incsearch_1.dump
new file mode 100644
index 0000000000..830b855d1d
--- /dev/null
+++ b/src/testdir/dumps/Test_smooth_incsearch_1.dump
@@ -0,0 +1,8 @@
+|<+0#4040ff13#ffffff0@2| +0#af5f00255&|a+0#0000000&@27| @7
+| +0#af5f00255&|1|2| | +0#0000000&@35
+| +0#af5f00255&|1|3| | +0#0000000&@35
+| +0#af5f00255&|1|4| |b+1#0000000&|b+0&&@2| @31
+| +0#af5f00255&|1|5| | +0#0000000&@35
+| +0#af5f00255&|1|6| | +0#0000000&@35
+| +0#af5f00255&|1|7| | +0#0000000&@35
+|/|b> @37
diff --git a/src/testdir/dumps/Test_smooth_incsearch_2.dump b/src/testdir/dumps/Test_smooth_incsearch_2.dump
new file mode 100644
index 0000000000..349e12861b
--- /dev/null
+++ b/src/testdir/dumps/Test_smooth_incsearch_2.dump
@@ -0,0 +1,8 @@
+|<+0#4040ff13#ffffff0@2| +0#af5f00255&|a+0#0000000&@27| @7
+| +0#af5f00255&|1|2| | +0#0000000&@35
+| +0#af5f00255&|1|3| | +0#0000000&@35
+| +0#af5f00255&|1|4| |b+1#0000000&@1|b+0&&@1| @31
+| +0#af5f00255&|1|5| | +0#0000000&@35
+| +0#af5f00255&|1|6| | +0#0000000&@35
+| +0#af5f00255&|1|7| | +0#0000000&@35
+|/|b@1> @36
diff --git a/src/testdir/dumps/Test_smooth_incsearch_3.dump b/src/testdir/dumps/Test_smooth_incsearch_3.dump
new file mode 100644
index 0000000000..0be3d21932
--- /dev/null
+++ b/src/testdir/dumps/Test_smooth_incsearch_3.dump
@@ -0,0 +1,8 @@
+|<+0#4040ff13#ffffff0@2| +0#af5f00255&|a+0#0000000&@27| @7
+| +0#af5f00255&|1|2| | +0#0000000&@35
+| +0#af5f00255&|1|3| | +0#0000000&@35
+| +0#af5f00255&|1|4| |b+1#0000000&@2|b+0&&| @31
+| +0#af5f00255&|1|5| | +0#0000000&@35
+| +0#af5f00255&|1|6| | +0#0000000&@35
+| +0#af5f00255&|1|7| | +0#0000000&@35
+|/|b@2> @35
diff --git a/src/testdir/dumps/Test_smooth_incsearch_4.dump b/src/testdir/dumps/Test_smooth_incsearch_4.dump
new file mode 100644
index 0000000000..c81c24b407
--- /dev/null
+++ b/src/testdir/dumps/Test_smooth_incsearch_4.dump
@@ -0,0 +1,8 @@
+|<+0#4040ff13#ffffff0@2| +0#af5f00255&|a+0#0000000&@27| @7
+| +0#af5f00255&|1|2| | +0#0000000&@35
+| +0#af5f00255&|1|3| | +0#0000000&@35
+| +0#af5f00255&|1|4| |b+1#0000000&@3| +0&&@31
+| +0#af5f00255&|1|5| | +0#0000000&@35
+| +0#af5f00255&|1|6| | +0#0000000&@35
+| +0#af5f00255&|1|7| | +0#0000000&@35
+|/|b@3> @34
diff --git a/src/testdir/dumps/Test_smooth_wrap_2.dump b/src/testdir/dumps/Test_smooth_wrap_2.dump
index fb0a981a8d..65a357dbb1 100644
--- a/src/testdir/dumps/Test_smooth_wrap_2.dump
+++ b/src/testdir/dumps/Test_smooth_wrap_2.dump
@@ -1,8 +1,8 @@
-|L+0&#ffffff0|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|
+|<+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
-|@+0#4040ff13&@2| @36
-| +0#0000000&@21|4|,|1| @10|4|0|%|
+@22|4|,|1| @10|2|5|%|
diff --git a/src/testdir/dumps/Test_smooth_wrap_4.dump b/src/testdir/dumps/Test_smooth_wrap_4.dump
index 1c42f64f48..c23f494dcd 100644
--- a/src/testdir/dumps/Test_smooth_wrap_4.dump
+++ b/src/testdir/dumps/Test_smooth_wrap_4.dump
@@ -2,7 +2,7 @@
|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|
+>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
+|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 469cf12719..648060bd58 100644
--- a/src/testdir/test_scroll_opt.vim
+++ b/src/testdir/test_scroll_opt.vim
@@ -257,11 +257,14 @@ func Test_smoothscroll_wrap_scrolloff_zero()
call term_sendkeys(buf, "G")
call VerifyScreenDump(buf, 'Test_smooth_wrap_4', {})
- " moving cursor up right after the >>> marker - no need to show whole line
+ call term_sendkeys(buf, "4\<C-Y>G")
+ call VerifyScreenDump(buf, 'Test_smooth_wrap_4', {})
+
+ " moving cursor up right after the <<< marker - no need to show whole line
call term_sendkeys(buf, "2gj3l2k")
call VerifyScreenDump(buf, 'Test_smooth_wrap_5', {})
- " moving cursor up where the >>> marker is - whole top line shows
+ " moving cursor up where the <<< marker is - whole top line shows
call term_sendkeys(buf, "2j02k")
call VerifyScreenDump(buf, 'Test_smooth_wrap_6', {})
@@ -705,4 +708,30 @@ func Test_smoothscroll_eob()
call StopVimInTerminal(buf)
endfunc
+" skipcol should not reset when doing incremental search on the same word
+func Test_smoothscroll_incsearch()
+ CheckScreendump
+
+ let lines =<< trim END
+ set smoothscroll number scrolloff=0 incsearch
+ call setline(1, repeat([''], 20))
+ call setline(11, repeat('a', 100))
+ call setline(14, 'bbbb')
+ END
+ call writefile(lines, 'XSmoothIncsearch', 'D')
+ let buf = RunVimInTerminal('-S XSmoothIncsearch', #{rows: 8, cols:40})
+
+ call term_sendkeys(buf, "/b")
+ call VerifyScreenDump(buf, 'Test_smooth_incsearch_1', {})
+ call term_sendkeys(buf, "b")
+ call VerifyScreenDump(buf, 'Test_smooth_incsearch_2', {})
+ call term_sendkeys(buf, "b")
+ call VerifyScreenDump(buf, 'Test_smooth_incsearch_3', {})
+ call term_sendkeys(buf, "b")
+ call VerifyScreenDump(buf, 'Test_smooth_incsearch_4', {})
+ call term_sendkeys(buf, "\<CR>")
+
+ call StopVimInTerminal(buf)
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/version.c b/src/version.c
index 42c2c0faed..54d927e05e 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 */
/**/
+ 1568,
+/**/
1567,
/**/
1566,