diff options
author | zeertzjq <zeertzjq@outlook.com> | 2024-04-09 07:08:52 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-09 07:08:52 +0800 |
commit | 66e86d3095447204d54991e98b83259e88affa9d (patch) | |
tree | 9218c97bc1076dd8cd84fac9588bbbd0578b049e /test | |
parent | 7035125b2b26aa68fcfb7cda39377ac79926a0f9 (diff) | |
parent | 8f5fd0884b4424d028feef1bccd018a48c93a59c (diff) | |
download | rneovim-66e86d3095447204d54991e98b83259e88affa9d.tar.gz rneovim-66e86d3095447204d54991e98b83259e88affa9d.tar.bz2 rneovim-66e86d3095447204d54991e98b83259e88affa9d.zip |
Merge pull request #28160 from luukvbaal/vim-9.1.0258
vim-patch:9.1.{0258,0260,0280}
Diffstat (limited to 'test')
-rw-r--r-- | test/functional/legacy/matchparen_spec.lua | 2 | ||||
-rw-r--r-- | test/functional/legacy/normal_spec.lua | 3 | ||||
-rw-r--r-- | test/old/testdir/test_diffmode.vim | 18 | ||||
-rw-r--r-- | test/old/testdir/test_edit.vim | 8 | ||||
-rw-r--r-- | test/old/testdir/test_normal.vim | 31 | ||||
-rw-r--r-- | test/old/testdir/test_scroll_opt.vim | 89 |
6 files changed, 121 insertions, 30 deletions
diff --git a/test/functional/legacy/matchparen_spec.lua b/test/functional/legacy/matchparen_spec.lua index db5a24e2e0..0a21efeb7c 100644 --- a/test/functional/legacy/matchparen_spec.lua +++ b/test/functional/legacy/matchparen_spec.lua @@ -19,7 +19,7 @@ describe('matchparen', function() call cursor(5, 1) ]]) - feed('V<c-d><c-d>3j') + feed('V<c-d><c-d>') screen:expect([[ {17:{} | {17:}} | 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<C-D>') 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_diffmode.vim b/test/old/testdir/test_diffmode.vim index 3e7eabf8f5..334bb3ee32 100644 --- a/test/old/testdir/test_diffmode.vim +++ b/test/old/testdir/test_diffmode.vim @@ -1664,8 +1664,7 @@ func Test_diff_scroll_many_filler() endfor set smoothscroll& - bwipe! - bwipe! + %bwipe! endfunc " This was trying to update diffs for a buffer being closed @@ -1773,4 +1772,19 @@ func Test_diff_toggle_wrap_skipcol_leftcol() bwipe! endfunc +" Ctrl-D reveals filler lines below the last line in the buffer. +func Test_diff_eob_halfpage() + 5new + call setline(1, ['']->repeat(10) + ['a']) + diffthis + 5new + call setline(1, ['']->repeat(3) + ['a', 'b']) + diffthis + wincmd j + exe "norm! G\<C-D>" + call assert_equal(6, line('w0')) + + %bwipe! +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/test/old/testdir/test_edit.vim b/test/old/testdir/test_edit.vim index 1bfe46c4a9..abd30074d5 100644 --- a/test/old/testdir/test_edit.vim +++ b/test/old/testdir/test_edit.vim @@ -1320,7 +1320,7 @@ func Test_edit_PAGEUP_PAGEDOWN() call feedkeys("A\<PageUp>\<esc>", 'tnix') call assert_equal([0, 10, 1, 0], getpos('.')) call feedkeys("A\<PageUp>\<esc>", 'tnix') - call assert_equal([0, 2, 11, 0], getpos('.')) + call assert_equal([0, 10, 11, 0], getpos('.')) " <S-Up> is the same as <PageUp> " <S-Down> is the same as <PageDown> call cursor(1, 1) @@ -1343,7 +1343,7 @@ func Test_edit_PAGEUP_PAGEDOWN() 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, 2, 11, 0], getpos('.')) + call assert_equal([0, 10, 11, 0], getpos('.')) set nostartofline call cursor(30, 11) norm! zt @@ -1356,7 +1356,7 @@ func Test_edit_PAGEUP_PAGEDOWN() call feedkeys("A\<PageUp>\<esc>", 'tnix') call assert_equal([0, 10, 11, 0], getpos('.')) call feedkeys("A\<PageUp>\<esc>", 'tnix') - call assert_equal([0, 2, 11, 0], getpos('.')) + call assert_equal([0, 10, 11, 0], getpos('.')) call cursor(1, 1) call feedkeys("A\<PageDown>\<esc>", 'tnix') call assert_equal([0, 9, 11, 0], getpos('.')) @@ -1381,7 +1381,7 @@ func Test_edit_PAGEUP_PAGEDOWN() 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, 2, 11, 0], getpos('.')) + call assert_equal([0, 10, 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/test/old/testdir/test_normal.vim b/test/old/testdir/test_normal.vim index 26270fddd2..10fbf4125a 100644 --- a/test/old/testdir/test_normal.vim +++ b/test/old/testdir/test_normal.vim @@ -1283,13 +1283,9 @@ func Test_vert_scroll_cmds() exe "normal \<C-D>" call assert_equal(46, line('.')) exe "normal \<C-U>" - call assert_equal(36, line('w0')) - call assert_equal(46, line('.')) - exe "normal \<C-U>" - call assert_equal(1, line('w0')) - call assert_equal(40, line('.')) + call assert_equal(36, line('.')) exe "normal \<C-U>" - call assert_equal(30, line('.')) + call assert_equal(1, line('.')) exe "normal \<C-U>" call assert_equal(1, line('.')) set scroll& @@ -1310,8 +1306,9 @@ 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(1, winline()) + call assert_equal(lnum, winline()) call assert_equal(50, line('.')) normal zt exe "normal \<C-D>" @@ -3080,8 +3077,7 @@ func Test_normal42_halfpage() call assert_equal(2, &scroll) set scroll=5 exe "norm! \<c-u>" - call assert_equal('3', getline('w0')) - call assert_equal('8', getline('.')) + call assert_equal('3', getline('.')) 1 set scrolloff=5 exe "norm! \<c-d>" @@ -3828,7 +3824,7 @@ func Test_normal_vert_scroll_longline() call assert_equal(1, winline()) exe "normal \<C-B>" call assert_equal(10, line('.')) - call assert_equal(10, winline()) + call assert_equal(4, winline()) exe "normal \<C-B>\<C-B>" call assert_equal(5, line('.')) call assert_equal(5, winline()) @@ -4224,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 \<C-E>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 575ce0c6b5..cb37b09707 100644 --- a/test/old/testdir/test_scroll_opt.vim +++ b/test/old/testdir/test_scroll_opt.vim @@ -552,14 +552,14 @@ func Test_smoothscroll_cursor_position() exe "normal \<C-Y>" call s:check_col_calc(1, 3, 41) - " Test "g0/g<Home>" + " 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& @@ -1020,26 +1020,93 @@ 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. + " Even with 'nostartofline', the correct amount of lines is scrolled. + setl nostartofline + exe "norm! 15|\<C-D>" call assert_equal(200, winsaveview().skipcol) + call assert_equal(215, col('.')) exe "norm! \<C-D>" call assert_equal(400, winsaveview().skipcol) + call assert_equal(415, col('.')) exe "norm! \<C-D>" - call assert_equal(600, winsaveview().skipcol) + call assert_equal(520, winsaveview().skipcol) + call assert_equal(535, col('.')) exe "norm! \<C-D>" - call assert_equal(800, winsaveview().skipcol) + call assert_equal(520, winsaveview().skipcol) + call assert_equal(735, col('.')) exe "norm! \<C-D>" - call assert_equal(880, winsaveview().skipcol) + call assert_equal(520, winsaveview().skipcol) + call assert_equal(895, col('.')) exe "norm! \<C-U>" - call assert_equal(680, winsaveview().skipcol) + call assert_equal(320, winsaveview().skipcol) + call assert_equal(695, col('.')) exe "norm! \<C-U>" - call assert_equal(480, winsaveview().skipcol) + call assert_equal(120, winsaveview().skipcol) + call assert_equal(495, col('.')) exe "norm! \<C-U>" - call assert_equal(280, winsaveview().skipcol) + call assert_equal(0, winsaveview().skipcol) + call assert_equal(375, col('.')) exe "norm! \<C-U>" - call assert_equal(80, winsaveview().skipcol) + call assert_equal(0, winsaveview().skipcol) + call assert_equal(175, col('.')) exe "norm! \<C-U>" call assert_equal(0, winsaveview().skipcol) + call assert_equal(15, 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) + + " Also when scrolling back. + exe "norm! G\<C-Y>" + redraw + call assert_equal(880, 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')) + + " Cursor does not end up above topline, adjusting topline later. + setlocal nu cpo+=n + exe "norm! G$g013\<C-Y>" + redraw + call assert_equal(2, line('.')) + call assert_equal(0, winsaveview().skipcol) + + set cpo-=n + 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 |