diff options
author | Luuk van Baal <luukvbaal@gmail.com> | 2024-03-28 10:07:29 +0100 |
---|---|---|
committer | Christian Brabandt <cb@256bit.org> | 2024-03-28 10:10:40 +0100 |
commit | 5a2e3ec9ac72b6e644fea4ebba7e632498296e2f (patch) | |
tree | 60995794ab4c3a4e3b53156b2b1b2fd4410d0ed1 /src/testdir | |
parent | 982e191b38b493d148d73871a724381214e4c62f (diff) |
patch 9.1.0215: Half-page scrolling does not support smooth-scrollingv9.1.0215
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>
Diffstat (limited to 'src/testdir')
-rw-r--r-- | src/testdir/dumps/Test_cursorline_redraw_2.dump | 14 | ||||
-rw-r--r-- | src/testdir/test_edit.vim | 32 | ||||
-rw-r--r-- | src/testdir/test_normal.vim | 26 | ||||
-rw-r--r-- | src/testdir/test_scroll_opt.vim | 29 |
4 files changed, 65 insertions, 36 deletions
diff --git a/src/testdir/dumps/Test_cursorline_redraw_2.dump b/src/testdir/dumps/Test_cursorline_redraw_2.dump index 323bef8e2c..d1b4e4e17c 100644 --- a/src/testdir/dumps/Test_cursorline_redraw_2.dump +++ b/src/testdir/dumps/Test_cursorline_redraw_2.dump @@ -1,20 +1,20 @@ -| +0&#ffffff0@39 -|T|h|e| |{|o|p|t|i|o|n|}| |a|r|g|u|m|e|n|t|s| |t|o| |"|:|s|e|t|"| |m|a|y| |b|e| +|T+0&#ffffff0|h|e| |{|o|p|t|i|o|n|}| |a|r|g|u|m|e|n|t|s| |t|o| |"|:|s|e|t|"| |m|a|y| |b|e| |r|e|p|e|a|t|e|d|.| @1|F|o|r| |e|x|a|m|p|l|e|:| |>| @14 -| +8&&@7>:|s|e|t| |a|i| |n|o|s|i| |s|w|=|3| |t|s|=|3| @9 -|I+0&&|f| |y|o|u| |m|a|k|e| |a|n| |e|r@1|o|r| |i|n| |o|n|e| |o|f| |t|h|e| |a|r|g|u|m +@8|:|s|e|t| |a|i| |n|o|s|i| |s|w|=|3| |t|s|=|3| @9 +|I|f| |y|o|u| |m|a|k|e| |a|n| |e|r@1|o|r| |i|n| |o|n|e| |o|f| |t|h|e| |a|r|g|u|m |e|n|t|s|,| |a|n| |e|r@1|o|r| |m|e|s@1|a|g|e| |w|i|l@1| |b|e| |g|i|v|e|n| @3 |a|n|d| |t|h|e| |f|o|l@1|o|w|i|n|g| |a|r|g|u|m|e|n|t|s| |w|i|l@1| |b|e| |i|g|n|o |r|e|d|.| @35 @40 @40 @16|*|:|s|e|t|-|v|e|r|b|o|s|e|*| @9 -|W|h|e|n| |'|v|e|r|b|o|s|e|'| |i|s| |n|o|n|-|z|e|r|o|,| |d|i|s|p|l|a|y|i|n|g| |a +>W+8&&|h|e|n| |'|v|e|r|b|o|s|e|'| |i|s| |n|o|n|-|z|e|r|o|,| |d|i|s|p|l|a|y|i|n|g| |a |n| |o|p|t|i|o|n| |v|a|l|u|e| |w|i|l@1| |a|l|s|o| |t|e|l@1| |w|h|e|r|e| |i|t| @1 -|w|a|s| |l|a|s|t| |s|e|t|.| @1|E|x|a|m|p|l|e|:| |>| @14 +|w+0&&|a|s| |l|a|s|t| |s|e|t|.| @1|E|x|a|m|p|l|e|:| |>| @14 @8|:|v|e|r|b|o|s|e| |s|e|t| |s|h|i|f|t|w|i|d|t|h| |c|i|n|d|e|n|t|? |<| @1|s|h|i|f|t|w|i|d|t|h|=|4| |~| @22 @10|L|a|s|t| |s|e|t| |f|r|o|m| |m|o|d|e|l|i|n|e| |l|i|n|e| |1| |~| @38 @2|c|i|n|d|e|n|t| |~| @28 -@22|7|,|2|-|9| @8|4@1|%| +|@+0#4040ff13&@2| @36 +| +0#0000000&@21|1|2|,|1| @9|5|0|%| diff --git a/src/testdir/test_edit.vim b/src/testdir/test_edit.vim index c81c244537..fbe7b9ba19 100644 --- a/src/testdir/test_edit.vim +++ b/src/testdir/test_edit.vim @@ -1294,15 +1294,15 @@ func Test_edit_PAGEUP_PAGEDOWN() call feedkeys("i\<PageDown>\<esc>", 'tnix') call assert_equal([0, 30, 1, 0], getpos('.')) call feedkeys("A\<PageUp>\<esc>", 'tnix') - call assert_equal([0, 30, 1, 0], getpos('.')) + call assert_equal([0, 29, 1, 0], getpos('.')) call feedkeys("A\<PageUp>\<esc>", 'tnix') - call assert_equal([0, 23, 1, 0], getpos('.')) + call assert_equal([0, 21, 1, 0], getpos('.')) call feedkeys("A\<PageUp>\<esc>", 'tnix') - call assert_equal([0, 15, 1, 0], getpos('.')) + call assert_equal([0, 13, 1, 0], getpos('.')) call feedkeys("A\<PageUp>\<esc>", 'tnix') call assert_equal([0, 10, 1, 0], getpos('.')) call feedkeys("A\<PageUp>\<esc>", 'tnix') - call assert_equal([0, 10, 11, 0], getpos('.')) + call assert_equal([0, 2, 11, 0], getpos('.')) " <S-Up> is the same as <PageUp> " <S-Down> is the same as <PageDown> call cursor(1, 1) @@ -1317,28 +1317,28 @@ func Test_edit_PAGEUP_PAGEDOWN() call feedkeys("i\<S-Down>\<esc>", 'tnix') call assert_equal([0, 30, 1, 0], getpos('.')) call feedkeys("A\<S-Up>\<esc>", 'tnix') - call assert_equal([0, 30, 1, 0], getpos('.')) + call assert_equal([0, 29, 1, 0], getpos('.')) call feedkeys("A\<S-Up>\<esc>", 'tnix') - call assert_equal([0, 23, 1, 0], getpos('.')) + call assert_equal([0, 21, 1, 0], getpos('.')) call feedkeys("A\<S-Up>\<esc>", 'tnix') - call assert_equal([0, 15, 1, 0], getpos('.')) + call assert_equal([0, 13, 1, 0], getpos('.')) call feedkeys("A\<S-Up>\<esc>", 'tnix') call assert_equal([0, 10, 1, 0], getpos('.')) call feedkeys("A\<S-Up>\<esc>", 'tnix') - call assert_equal([0, 10, 11, 0], getpos('.')) + call assert_equal([0, 2, 11, 0], getpos('.')) set nostartofline call cursor(30, 11) norm! zt call feedkeys("A\<PageUp>\<esc>", 'tnix') - call assert_equal([0, 30, 11, 0], getpos('.')) + call assert_equal([0, 29, 11, 0], getpos('.')) call feedkeys("A\<PageUp>\<esc>", 'tnix') - call assert_equal([0, 23, 11, 0], getpos('.')) + call assert_equal([0, 21, 11, 0], getpos('.')) call feedkeys("A\<PageUp>\<esc>", 'tnix') - call assert_equal([0, 15, 11, 0], getpos('.')) + call assert_equal([0, 13, 11, 0], getpos('.')) call feedkeys("A\<PageUp>\<esc>", 'tnix') call assert_equal([0, 10, 11, 0], getpos('.')) call feedkeys("A\<PageUp>\<esc>", 'tnix') - call assert_equal([0, 10, 11, 0], getpos('.')) + call assert_equal([0, 2, 11, 0], getpos('.')) call cursor(1, 1) call feedkeys("A\<PageDown>\<esc>", 'tnix') call assert_equal([0, 9, 11, 0], getpos('.')) @@ -1355,15 +1355,15 @@ func Test_edit_PAGEUP_PAGEDOWN() call cursor(30, 11) norm! zt call feedkeys("A\<S-Up>\<esc>", 'tnix') - call assert_equal([0, 30, 11, 0], getpos('.')) + call assert_equal([0, 29, 11, 0], getpos('.')) call feedkeys("A\<S-Up>\<esc>", 'tnix') - call assert_equal([0, 23, 11, 0], getpos('.')) + call assert_equal([0, 21, 11, 0], getpos('.')) call feedkeys("A\<S-Up>\<esc>", 'tnix') - call assert_equal([0, 15, 11, 0], getpos('.')) + call assert_equal([0, 13, 11, 0], getpos('.')) call feedkeys("A\<S-Up>\<esc>", 'tnix') call assert_equal([0, 10, 11, 0], getpos('.')) call feedkeys("A\<S-Up>\<esc>", 'tnix') - call assert_equal([0, 10, 11, 0], getpos('.')) + call assert_equal([0, 2, 11, 0], getpos('.')) call cursor(1, 1) call feedkeys("A\<S-Down>\<esc>", 'tnix') call assert_equal([0, 9, 11, 0], getpos('.')) diff --git a/src/testdir/test_normal.vim b/src/testdir/test_normal.vim index dd2f2be2f9..3a7248fd08 100644 --- a/src/testdir/test_normal.vim +++ b/src/testdir/test_normal.vim @@ -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! diff --git a/src/testdir/test_scroll_opt.vim b/src/testdir/test_scroll_opt.vim index 24804956f4..788870f876 100644 --- a/src/testdir/test_scroll_opt.vim +++ b/src/testdir/test_scroll_opt.vim @@ -1005,18 +1005,39 @@ func Test_smoothscroll_page() call setline(1, 'abcde '->repeat(150)) exe "norm! \<C-F>" - call assert_equal(320, winsaveview().skipcol) + call assert_equal(400, winsaveview().skipcol) exe "norm! \<C-F>" - call assert_equal(640, winsaveview().skipcol) + call assert_equal(800, winsaveview().skipcol) exe "norm! \<C-F>" call assert_equal(880, winsaveview().skipcol) exe "norm! \<C-B>" - call assert_equal(560, winsaveview().skipcol) + call assert_equal(480, winsaveview().skipcol) exe "norm! \<C-B>" - call assert_equal(240, winsaveview().skipcol) + call assert_equal(80, winsaveview().skipcol) exe "norm! \<C-B>" call assert_equal(0, winsaveview().skipcol) + exe "norm! \<C-D>" + call assert_equal(200, winsaveview().skipcol) + exe "norm! \<C-D>" + call assert_equal(400, winsaveview().skipcol) + exe "norm! \<C-D>" + call assert_equal(600, winsaveview().skipcol) + exe "norm! \<C-D>" + call assert_equal(800, winsaveview().skipcol) + exe "norm! \<C-D>" + call assert_equal(880, winsaveview().skipcol) + exe "norm! \<C-U>" + call assert_equal(680, winsaveview().skipcol) + exe "norm! \<C-U>" + call assert_equal(480, winsaveview().skipcol) + exe "norm! \<C-U>" + call assert_equal(280, winsaveview().skipcol) + exe "norm! \<C-U>" + call assert_equal(80, winsaveview().skipcol) + exe "norm! \<C-U>" + call assert_equal(0, winsaveview().skipcol) + set smoothscroll& endfunc |