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>
diff --git a/src/testdir/test_normal.vim b/src/testdir/test_normal.vim
index dd2f2be..3a7248f 100644
--- a/src/testdir/test_normal.vim
+++ b/src/testdir/test_normal.vim
@@ -1280,9 +1280,13 @@
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 @@
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 @@
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 @@
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 @@
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!