patch 9.0.0900: cursor moves too far with 'smoothscroll'
Problem: Cursor moves too far with 'smoothscroll'.
Solution: Only move as far as really needed. (Yee Cheng Chin, closes #11504)
diff --git a/src/testdir/test_scroll_opt.vim b/src/testdir/test_scroll_opt.vim
index 76853af..3975a1f 100644
--- a/src/testdir/test_scroll_opt.vim
+++ b/src/testdir/test_scroll_opt.vim
@@ -230,10 +230,14 @@
call term_sendkeys(buf, "G")
call VerifyScreenDump(buf, 'Test_smooth_wrap_4', {})
- " moving cursor up - whole top line shows
- call term_sendkeys(buf, "2k")
+ " 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
+ call term_sendkeys(buf, "2j02k")
+ call VerifyScreenDump(buf, 'Test_smooth_wrap_6', {})
+
call StopVimInTerminal(buf)
endfunc
@@ -321,7 +325,6 @@
let buf = RunVimInTerminal('-S XSmoothLongShowbreak', #{rows: 6, cols: 40})
call VerifyScreenDump(buf, 'Test_smooth_long_showbreak_1', {})
- " FIXME: this currently has the cursor in screen line 2, should be one up.
call term_sendkeys(buf, "\<C-E>")
call VerifyScreenDump(buf, 'Test_smooth_long_showbreak_2', {})
@@ -353,10 +356,16 @@
call s:check_col_calc(1, 2, 41)
exe "normal \<C-Y>"
call s:check_col_calc(1, 3, 41)
- normal ggg$
+
+ normal gg3l
exe "normal \<C-E>"
" Move down only 1 line when we are out of the range of the <<< display
+ call s:check_col_calc(4, 1, 24)
+ exe "normal \<C-Y>"
+ call s:check_col_calc(4, 2, 24)
+ normal ggg$
+ exe "normal \<C-E>"
call s:check_col_calc(20, 1, 40)
exe "normal \<C-Y>"
call s:check_col_calc(20, 2, 40)
@@ -366,9 +375,11 @@
setl number
call s:check_col_calc(5, 1, 1)
exe "normal \<C-E>"
- call s:check_col_calc(5, 2, 33)
+
+ " Move down only 1 line when the <<< display is on the number column
+ call s:check_col_calc(5, 1, 17)
exe "normal \<C-Y>"
- call s:check_col_calc(5, 3, 33)
+ call s:check_col_calc(5, 2, 17)
normal ggg$
exe "normal \<C-E>"
call s:check_col_calc(20, 1, 32)
@@ -376,13 +387,33 @@
call s:check_col_calc(20, 2, 32)
normal gg
+ setl numberwidth=1
+
+ " Move down another line when numberwidth is too short to cover the whole
+ " <<< display
+ call s:check_col_calc(3, 1, 1)
+ exe "normal \<C-E>"
+ call s:check_col_calc(3, 2, 37)
+ exe "normal \<C-Y>"
+ call s:check_col_calc(3, 3, 37)
+ normal ggl
+
+ " Only move 1 line down when we are just past the <<< display
+ call s:check_col_calc(4, 1, 2)
+ exe "normal \<C-E>"
+ call s:check_col_calc(4, 1, 20)
+ exe "normal \<C-Y>"
+ call s:check_col_calc(4, 2, 20)
+ normal gg
+ setl numberwidth&
+
" Test number + showbreak, so test that the additional indentation works
setl number showbreak=+++
call s:check_col_calc(5, 1, 1)
exe "normal \<C-E>"
- call s:check_col_calc(8, 2, 30)
+ call s:check_col_calc(8, 1, 17)
exe "normal \<C-Y>"
- call s:check_col_calc(8, 3, 30)
+ call s:check_col_calc(8, 2, 17)
normal gg
" Test number + cpo+=n mode, where wrapped lines aren't indented