From e21423bb35077fe4bbb6a8fab1000e8bfc6b6b7b Mon Sep 17 00:00:00 2001 From: Luuk van Baal Date: Wed, 3 Apr 2024 23:06:23 +0200 Subject: vim-patch:9.1.0260: Problems with "zb" and scrolling to new topline with 'smoothscroll' Problem: "zb" does not reveal filler lines at the start of a buffer. Scrolled cursor position with 'smoothscroll' is unpredictable, and may reset skipcol later if it is not visible (after v9.1.258) Solution: Replace confusing for loop that reaches final control value too early with while loop. Set "w_curswant" accordingly so cursor will be placed in visible part of topline. (Luuk van Baal) https://github.com/vim/vim/commit/bd28cae1f1c21c0e3743e3427c98bbd848fad237 --- test/functional/legacy/normal_spec.lua | 3 +-- test/old/testdir/test_normal.vim | 15 +++++++++++++++ test/old/testdir/test_scroll_opt.vim | 9 ++++++++- 3 files changed, 24 insertions(+), 3 deletions(-) (limited to 'test') diff --git a/test/functional/legacy/normal_spec.lua b/test/functional/legacy/normal_spec.lua index 113f7c668a..c57e51c18e 100644 --- a/test/functional/legacy/normal_spec.lua +++ b/test/functional/legacy/normal_spec.lua @@ -94,10 +94,9 @@ describe('normal', function() feed('ggG') screen:expect({ grid = [[ - foobar one two three |*8 + foobar one two three |*16 ^foobar one two three | {2:---} | - {1:~ }|*8 | ]], }) diff --git a/test/old/testdir/test_normal.vim b/test/old/testdir/test_normal.vim index 013d8959ca..10fbf4125a 100644 --- a/test/old/testdir/test_normal.vim +++ b/test/old/testdir/test_normal.vim @@ -4220,4 +4220,19 @@ func Test_single_line_scroll() call prop_type_delete(vt) endfunc +" Test for zb in buffer with a single line and filler lines +func Test_single_line_filler_zb() + call setline(1, ['', 'foobar one two three']) + diffthis + new + call setline(1, ['foobar one two three']) + diffthis + + " zb scrolls to reveal filler lines at the start of the buffer. + exe "normal \zb" + call assert_equal(1, winsaveview().topfill) + + bw! +endfunc + " vim: shiftwidth=2 sts=2 expandtab nofoldenable diff --git a/test/old/testdir/test_scroll_opt.vim b/test/old/testdir/test_scroll_opt.vim index 4e551cdaad..d381456032 100644 --- a/test/old/testdir/test_scroll_opt.vim +++ b/test/old/testdir/test_scroll_opt.vim @@ -1021,6 +1021,8 @@ func Test_smoothscroll_page() call assert_equal(0, winsaveview().skipcol) " Half-page scrolling does not go beyond end of buffer and moves the cursor. + " Even with 'nostartofline', the correct amount of lines is scrolled. + setl nostartofline exe "norm! 0\" call assert_equal(200, winsaveview().skipcol) call assert_equal(204, col('.')) @@ -1044,7 +1046,7 @@ func Test_smoothscroll_page() call assert_equal(204, col('.')) exe "norm! \" call assert_equal(0, winsaveview().skipcol) - call assert_equal(1, col('.')) + call assert_equal(40, col('.')) bwipe! endfunc @@ -1062,6 +1064,11 @@ func Test_smoothscroll_next_topline() redraw call assert_equal(0, winsaveview().skipcol) + " Also when scrolling back. + exe "norm! G\" + redraw + call assert_equal(880, winsaveview().skipcol) + " Cursor in correct place when not in the first screenline of a buffer line. exe "norm! gg4gj20\\" redraw -- cgit