1
0
forked from aniani/vim

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)
This commit is contained in:
Yee Cheng Chin
2022-11-18 12:52:50 +00:00
committed by Bram Moolenaar
parent 4654d63dec
commit 81ba26e9de
7 changed files with 101 additions and 26 deletions

View File

@@ -1,6 +1,6 @@
|++0#4040ff13#ffffff0@2| |o+0#0000000&|f| |t|e|x|t| |i|n| |o|n|e| |l|i|n|e| |w|i|t|h| |l|o|t|s| |o|f| |t|e|x
|++0#4040ff13&@2| >t+0#0000000&| |i|n| |o|n|e| |l|i|n|e| |w|i|t|h| |l|o|t|s| |o|f| |t|e|x|t| |i|n| |o
|++0#4040ff13#ffffff0@2| >o+0#0000000&|f| |t|e|x|t| |i|n| |o|n|e| |l|i|n|e| |w|i|t|h| |l|o|t|s| |o|f| |t|e|x
|++0#4040ff13&@2| |t+0#0000000&| |i|n| |o|n|e| |l|i|n|e| |w|i|t|h| |l|o|t|s| |o|f| |t|e|x|t| |i|n| |o
|++0#4040ff13&@2| |n+0#0000000&|e| |l|i|n|e| |w|i|t|h| |l|o|t|s| |o|f| |t|e|x|t| |i|n| |o|n|e| |l|i|n
|++0#4040ff13&@2| |e+0#0000000&| |w|i|t|h| |l|o|t|s| |o|f| |t|e|x|t| |i|n| |o|n|e| |l|i|n|e| @4
|~+0#4040ff13&| @38
| +0#0000000&@21|1|,|7@1|-|8|5| @6|A|l@1|
| +0#0000000&@21|1|,|4|1|-|4|5| @6|A|l@1|

View File

@@ -1,5 +1,5 @@
|2+0#af5f00255#ffffff0|<+0#4040ff13&@2|o+0#0000000&|n|g| |t|e|x|t| |v|e|r|y| |l|o|n|g| |t|e|x|t| |v|e|r|y| |l|o|n|g| |t|e
| +0#af5f00255&@3>x+0#0000000&|t| |v|e|r|y| |l|o|n|g| |t|e|x|t| |v|e|r|y| |l|o|n|g| |t|e|x|t| |v|e|r
|2+0#af5f00255#ffffff0|<+0#4040ff13&@2>o+0#0000000&|n|g| |t|e|x|t| |v|e|r|y| |l|o|n|g| |t|e|x|t| |v|e|r|y| |l|o|n|g| |t|e
| +0#af5f00255&@3|x+0#0000000&|t| |v|e|r|y| |l|o|n|g| |t|e|x|t| |v|e|r|y| |l|o|n|g| |t|e|x|t| |v|e|r
| +0#af5f00255&@3|y+0#0000000&| |l|o|n|g| |t|e|x|t| |v|e|r|y| |l|o|n|g| |t|e|x|t| |v|e|r|y| |l|o|n|g
| +0#af5f00255&@3| +0#0000000&|t|e|x|t| |v|e|r|y| |l|o|n|g| |t|e|x|t| |v|e|r|y| |l|o|n|g| |t|e|x|t|
| +0#af5f00255&@1|1| |t+0#0000000&|h|r|e@1| @30
@@ -9,4 +9,4 @@
|~| @38
|~| @38
|~| @38
|-+0#0000000&@1|N|o|.@2|e|r|-@1| @10|2|,|7|3| @9|B|o|t|
|-+0#0000000&@1|N|o|.@2|e|r|-@1| @10|2|,|3|7| @9|B|o|t|

View File

@@ -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|5|,|1| @10|8|0|%|
@22|5|,|8|4| @9|B|o|t|

View File

@@ -0,0 +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|
|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|5|,|1| @10|8|0|%|

View File

@@ -230,10 +230,14 @@ func Test_smoothscroll_wrap_scrolloff_zero()
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 @@ func Test_smoothscroll_long_line_showbreak()
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 @@ func Test_smoothscroll_cursor_position()
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 @@ func Test_smoothscroll_cursor_position()
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 @@ func Test_smoothscroll_cursor_position()
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