Mercurial > vim
diff src/testdir/test_scroll_opt.vim @ 34761:b20609f4ab37 v9.1.0258
patch 9.1.0258: half-page scrolling broke backward compatibility
Commit: https://github.com/vim/vim/commit/cb204e688e5c9d56a78b621ef27c35d91860cb09
Author: Luuk van Baal <luukvbaal@gmail.com>
Date: Tue Apr 2 20:49:45 2024 +0200
patch 9.1.0258: half-page scrolling broke backward compatibility
Problem: Support for 'smoothscroll' in (half-)page scrolling
broke backward compatibility and can be made to work better.
(after v9.1.215)
Solution: Restore the previous cursor and end-of-buffer behavior for
half-page scrolling and improve 'smoothscroll' support.
(Luuk van Baal)
fixes: #14338
closes: #14377
Signed-off-by: Luuk van Baal <luukvbaal@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Tue, 02 Apr 2024 21:00:06 +0200 |
parents | 5569220366ee |
children | be09936c20c7 |
line wrap: on
line diff
--- a/src/testdir/test_scroll_opt.vim +++ b/src/testdir/test_scroll_opt.vim @@ -552,11 +552,11 @@ func Test_smoothscroll_cursor_position() " Test "g0/g<Home>" exe "normal gg\<C-E>" norm $gkg0 - call s:check_col_calc(1, 2, 21) + call s:check_col_calc(4, 1, 24) " Test moving the cursor behind the <<< display with 'virtualedit' set virtualedit=all - exe "normal \<C-E>3lgkh" + exe "normal \<C-E>gkh" call s:check_col_calc(3, 2, 23) set virtualedit& @@ -1017,26 +1017,72 @@ func Test_smoothscroll_page() exe "norm! \<C-B>" call assert_equal(0, winsaveview().skipcol) - exe "norm! \<C-D>" + " Half-page scrolling does not go beyond end of buffer and moves the cursor. + exe "norm! 0\<C-D>" call assert_equal(200, winsaveview().skipcol) + call assert_equal(204, col('.')) exe "norm! \<C-D>" call assert_equal(400, winsaveview().skipcol) - exe "norm! \<C-D>" - call assert_equal(600, winsaveview().skipcol) + call assert_equal(404, col('.')) exe "norm! \<C-D>" - call assert_equal(800, winsaveview().skipcol) + call assert_equal(520, winsaveview().skipcol) + call assert_equal(601, col('.')) exe "norm! \<C-D>" - call assert_equal(880, winsaveview().skipcol) + call assert_equal(520, winsaveview().skipcol) + call assert_equal(801, col('.')) exe "norm! \<C-U>" - call assert_equal(680, winsaveview().skipcol) - exe "norm! \<C-U>" - call assert_equal(480, winsaveview().skipcol) + call assert_equal(520, winsaveview().skipcol) + call assert_equal(601, col('.')) exe "norm! \<C-U>" - call assert_equal(280, winsaveview().skipcol) + call assert_equal(400, winsaveview().skipcol) + call assert_equal(404, col('.')) exe "norm! \<C-U>" - call assert_equal(80, winsaveview().skipcol) + call assert_equal(200, winsaveview().skipcol) + call assert_equal(204, col('.')) exe "norm! \<C-U>" call assert_equal(0, winsaveview().skipcol) + call assert_equal(1, col('.')) + + bwipe! +endfunc + +func Test_smoothscroll_next_topline() + call NewWindow(10, 40) + setlocal smoothscroll + call setline(1, ['abcde '->repeat(150)]->repeat(2)) + + " Scrolling a screenline that causes the cursor to move to the next buffer + " line should not skip part of that line to bring the cursor into view. + exe "norm! 22\<C-E>" + call assert_equal(880, winsaveview().skipcol) + exe "norm! \<C-E>" + redraw + call assert_equal(0, winsaveview().skipcol) + + " Cursor in correct place when not in the first screenline of a buffer line. + exe "norm! gg4gj20\<C-D>\<C-D>" + redraw + call assert_equal(2, line('w0')) + + bwipe! +endfunc + +func Test_smoothscroll_long_line_zb() + call NewWindow(10, 40) + call setline(1, 'abcde '->repeat(150)) + + " Also works without 'smoothscroll' when last line of buffer doesn't fit. + " Used to set topline to buffer line count plus one, causing an empty screen. + norm zb + redraw + call assert_equal(1, winsaveview().topline) + + " Moving cursor to bottom works on line that doesn't fit with 'smoothscroll'. + " Skipcol was adjusted later for cursor being on not visible part of line. + setlocal smoothscroll + norm zb + redraw + call assert_equal(520, winsaveview().skipcol) bwipe! endfunc