1
0
forked from aniani/vim

patch 9.1.0215: Half-page scrolling does not support smooth-scrolling

Problem:  Page-wise scrolling with Ctrl-D/Ctrl-U implements
          it's own logic to change the topline and cursor.
          More logic than necessary for scrolling with Ctrl-F/Ctrl-B
          was removed in patch 9.1.0211.
Solution: Re-use the logic from Ctrl-E/Ctrl-Y/Ctrl-F/Ctrl-B while
          staying backward compatible as much as possible.
          Restore some of the logic that determined how many lines will
          be scrolled (Luuk van Baal)

closes: #14316

Signed-off-by: Luuk van Baal <luukvbaal@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Luuk van Baal
2024-03-28 10:07:29 +01:00
committed by Christian Brabandt
parent 982e191b38
commit 5a2e3ec9ac
12 changed files with 166 additions and 242 deletions

View File

@@ -1280,9 +1280,13 @@ func Test_vert_scroll_cmds()
exe "normal \<C-D>"
call assert_equal(46, line('.'))
exe "normal \<C-U>"
call assert_equal(36, line('.'))
call assert_equal(36, line('w0'))
call assert_equal(46, line('.'))
exe "normal \<C-U>"
call assert_equal(10, line('.'))
call assert_equal(1, line('w0'))
call assert_equal(40, line('.'))
exe "normal \<C-U>"
call assert_equal(30, line('.'))
exe "normal \<C-U>"
call assert_equal(1, line('.'))
set scroll&
@@ -1303,9 +1307,8 @@ func Test_vert_scroll_cmds()
call assert_equal(50, line('.'))
call assert_equal(100, line('w$'))
normal z.
let lnum = winline()
exe "normal \<C-D>"
call assert_equal(lnum, winline())
call assert_equal(1, winline())
call assert_equal(50, line('.'))
normal zt
exe "normal \<C-D>"
@@ -3066,7 +3069,8 @@ func Test_normal42_halfpage()
call assert_equal(2, &scroll)
set scroll=5
exe "norm! \<c-u>"
call assert_equal('3', getline('.'))
call assert_equal('3', getline('w0'))
call assert_equal('8', getline('.'))
1
set scrolloff=5
exe "norm! \<c-d>"
@@ -3813,11 +3817,11 @@ func Test_normal_vert_scroll_longline()
call assert_equal(11, line('.'))
call assert_equal(1, winline())
exe "normal \<C-B>"
call assert_equal(11, line('.'))
call assert_equal(9, winline())
call assert_equal(10, line('.'))
call assert_equal(10, winline())
exe "normal \<C-B>\<C-B>"
call assert_equal(5, line('.'))
call assert_equal(1, winline())
call assert_equal(5, winline())
bwipe!
endfunc
@@ -4186,12 +4190,16 @@ func Test_single_line_scroll()
norm! {
call assert_equal([0, 1, 1, 0], getpos('.'))
" Ctrl-B scrolls up with hidden "above" virtual text.
" Ctrl-B/Ctrl-U scroll up with hidden "above" virtual text.
set smoothscroll
exe "normal \<C-E>"
call assert_notequal(0, winsaveview().skipcol)
exe "normal \<C-B>"
call assert_equal(0, winsaveview().skipcol)
exe "normal \<C-E>"
call assert_notequal(0, winsaveview().skipcol)
exe "normal \<C-U>"
call assert_equal(0, winsaveview().skipcol)
set smoothscroll&
bw!