From abf42b7ec6b408d4b4ce8c66b6a8a77c638d3c75 Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Mon, 14 Feb 2022 13:08:00 +0000 Subject: test(old): cherry-pick test_visual changes from v8.2.0369 https://github.com/vim/vim/commit/1671f4488105ee12a6a8558ae351436c26ab55fc Omit Test_AAA_start_visual_mode_with_count comment change as it hasn't been ported yet. --- src/nvim/testdir/test_visual.vim | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) (limited to 'src/nvim/testdir/test_visual.vim') diff --git a/src/nvim/testdir/test_visual.vim b/src/nvim/testdir/test_visual.vim index 099a90643f..2fc7fd0e9c 100644 --- a/src/nvim/testdir/test_visual.vim +++ b/src/nvim/testdir/test_visual.vim @@ -132,11 +132,16 @@ func Test_blockwise_visual_o_O() exe "norm! gvO\rb" exe "norm! gvo\rc" exe "norm! gvO\rd" + set selection=exclusive + exe "norm! gvOo\re" + call assert_equal('...a be.', getline(4)) + exe "norm! gvOO\rf" + set selection& call assert_equal(['..........', \ '...c d..', \ '... ..', - \ '...a b..', + \ '...a bf.', \ '..........'], getline(1, '$')) enew! @@ -658,6 +663,16 @@ func Test_characterwise_select_mode() exe "normal Gkgh\\\" call assert_equal(['', 'a', ''], getline(1, '$')) + " CTRL-H in select mode behaves like 'x' + call setline(1, 'abcdef') + exe "normal! gggh\\\\" + call assert_equal('ef', getline(1)) + + " CTRL-O in select mode switches to visual mode for one command + call setline(1, 'abcdef') + exe "normal! gggh\3lm" + call assert_equal('mef', getline(1)) + sunmap End> sunmap Down> sunmap Del> @@ -757,8 +772,7 @@ endfunc func Test_visual_block_mode() new call append(0, '') - call setline(1, ['abcdefghijklm', 'abcdefghijklm', 'abcdefghijklm', - \ 'abcdefghijklm', 'abcdefghijklm']) + call setline(1, repeat(['abcdefghijklm'], 5)) call cursor(1, 1) " Test shift-right of a block @@ -777,6 +791,16 @@ func Test_visual_block_mode() \ 'axyzqqqqefgmnoklm', \ 'abcdqqqqijklm'], getline(1, 5)) + " Test 'C' to change till the end of the line + call cursor(3, 4) + exe "normal! \j3lCooo" + call assert_equal(['axyooo', 'axyooo'], getline(3, 4)) + + " Test 'D' to delete till the end of the line + call cursor(3, 3) + exe "normal! \j2lD" + call assert_equal(['ax', 'ax'], getline(3, 4)) + " Test from ':help v_b_I_example' %d _ setlocal tabstop=8 shiftwidth=4 -- cgit From b7e6c1b525613bd0ece6fde8c1bcbc52fdc9372f Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Mon, 14 Feb 2022 13:20:26 +0000 Subject: test(old): cherry-pick test_visual changes from v8.2.2901 https://github.com/vim/vim/commit/3e72dcad8b752a42b6eaf71213e3f5d534175256 --- src/nvim/testdir/test_visual.vim | 101 ++++++++++++++++++++++++++++++++++----- 1 file changed, 89 insertions(+), 12 deletions(-) (limited to 'src/nvim/testdir/test_visual.vim') diff --git a/src/nvim/testdir/test_visual.vim b/src/nvim/testdir/test_visual.vim index 2fc7fd0e9c..2c79ed25f5 100644 --- a/src/nvim/testdir/test_visual.vim +++ b/src/nvim/testdir/test_visual.vim @@ -59,7 +59,7 @@ endfunc " Test for visual block shift and tab characters. func Test_block_shift_tab() - enew! + new call append(0, repeat(['one two three'], 5)) call cursor(1,1) exe "normal i\u" @@ -68,7 +68,7 @@ func Test_block_shift_tab() call assert_equal('on1 two three', getline(2)) call assert_equal('on1 two three', getline(5)) - enew! + %d _ call append(0, repeat(['abcdefghijklmnopqrstuvwxyz'], 5)) call cursor(1,1) exe "normal \4jI \j<<11|D" @@ -93,12 +93,26 @@ func Test_block_shift_tab() call assert_equal(" abc\\defghijklmnopqrstuvwxyz", getline(4)) call assert_equal(" abc\ defghijklmnopqrstuvwxyz", getline(5)) - enew! + " Test for block shift with space characters at the beginning and with + " 'noexpandtab' and 'expandtab' + %d _ + call setline(1, [" 1", " 2", " 3"]) + setlocal shiftwidth=2 noexpandtab + exe "normal gg\3j>" + call assert_equal(["\t1", "\t2", "\t3"], getline(1, '$')) + %d _ + call setline(1, [" 1", " 2", " 3"]) + setlocal shiftwidth=2 expandtab + exe "normal gg\3j>" + call assert_equal([" 1", " 2", " 3"], getline(1, '$')) + setlocal shiftwidth& + + bw! endfunc " Tests Blockwise Visual when there are TABs before the text. func Test_blockwise_visual() - enew! + new call append(0, ['123456', \ '234567', \ '345678', @@ -120,12 +134,12 @@ func Test_blockwise_visual() \ "\t\tsomext", \ "\t\ttesext"], getline(1, 7)) - enew! + bw! endfunc " Test swapping corners in blockwise visual mode with o and O func Test_blockwise_visual_o_O() - enew! + new exe "norm! 10i.\Y4P3lj\4l2jr " exe "norm! gvO\ra" @@ -144,7 +158,7 @@ func Test_blockwise_visual_o_O() \ '...a bf.', \ '..........'], getline(1, '$')) - enew! + bw! endfun " Test Virtual replace mode. @@ -273,7 +287,6 @@ func Test_visual_mode_reset() " thus preventing the problem: exe "normal! GV:call TriggerTheProblem()\" call assert_equal("Everything's fine.", g:msg) - endfunc func Test_Visual_word_textobject() @@ -440,15 +453,13 @@ endfunc " Test for 'p'ut in visual block mode func Test_visual_block_put() - enew - + new call append(0, ['One', 'Two', 'Three']) normal gg yank call feedkeys("jl\ljp", 'xt') call assert_equal(['One', 'T', 'Tee', 'One', ''], getline(1, '$')) - - enew! + bw! endfunc func Test_visual_put_in_block() @@ -628,6 +639,12 @@ func Test_characterwise_visual_mode() normal Gkvj$d call assert_equal(['', 'a', ''], getline(1, '$')) + " characterwise visual mode: replace a single character line and the eol + %d _ + call setline(1, "a") + normal v$rx + call assert_equal(['x'], getline(1, '$')) + bwipe! endfunc @@ -801,6 +818,66 @@ func Test_visual_block_mode() exe "normal! \j2lD" call assert_equal(['ax', 'ax'], getline(3, 4)) + " Test block insert with a short line that ends before the block + %d _ + call setline(1, [" one", "a", " two"]) + exe "normal gg\2jIx" + call assert_equal([" xone", "a", " xtwo"], getline(1, '$')) + + " Test block append at EOL with '$' and without '$' + %d _ + call setline(1, ["one", "a", "two"]) + exe "normal gg$\2jAx" + call assert_equal(["onex", "ax", "twox"], getline(1, '$')) + %d _ + call setline(1, ["one", "a", "two"]) + exe "normal gg3l\2jAx" + call assert_equal(["onex", "a x", "twox"], getline(1, '$')) + + " Test block replace with an empty line in the middle and use $ to jump to + " the end of the line. + %d _ + call setline(1, ['one', '', 'two']) + exe "normal gg$\2jrx" + call assert_equal(["onx", "", "twx"], getline(1, '$')) + + " Test block replace with an empty line in the middle and move cursor to the + " end of the line + %d _ + call setline(1, ['one', '', 'two']) + exe "normal gg2l\2jrx" + call assert_equal(["onx", "", "twx"], getline(1, '$')) + + " Replace odd number of characters with a multibyte character + %d _ + call setline(1, ['abcd', 'efgh']) + exe "normal ggl\2ljr\u1100" + call assert_equal(["a\u1100 ", "e\u1100 "], getline(1, '$')) + + " During visual block append, if the cursor moved outside of the selected + " range, then the edit should not be applied to the block. + %d _ + call setline(1, ['aaa', 'bbb', 'ccc']) + exe "normal 2G\jAx\" + call assert_equal(['aaa', 'bxbb', 'ccc'], getline(1, '$')) + + " During visual block append, if the cursor is moved before the start of the + " block, then the new text should be appended there. + %d _ + call setline(1, ['aaa', 'bbb', 'ccc']) + exe "normal $\2jA\x" + " BUG: Instead of adding x as the third character in all the three lines, + " 'a' is added in the second and third lines at the end. This bug is not + " reproducible if this operation is performed manually. + "call assert_equal(['aaxa', 'bbxb', 'ccxc'], getline(1, '$')) + call assert_equal(['aaxa', 'bbba', 'ccca'], getline(1, '$')) + + " Change a characterwise motion to a blockwise motion using CTRL-V + %d _ + call setline(1, ['123', '456', '789']) + exe "normal ld\j" + call assert_equal(['13', '46', '789'], getline(1, '$')) + " Test from ':help v_b_I_example' %d _ setlocal tabstop=8 shiftwidth=4 -- cgit From d5d51308c0e531f6c2dec6b5570b3ffe04ab6b45 Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Mon, 14 Feb 2022 13:26:42 +0000 Subject: test(old): cherry-pick test_visual changes from v8.2.2945 https://github.com/vim/vim/commit/59b262362f26b3aaea1eeb0078adc33eed59863e --- src/nvim/testdir/test_visual.vim | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/nvim/testdir/test_visual.vim') diff --git a/src/nvim/testdir/test_visual.vim b/src/nvim/testdir/test_visual.vim index 2c79ed25f5..d05035b4e9 100644 --- a/src/nvim/testdir/test_visual.vim +++ b/src/nvim/testdir/test_visual.vim @@ -871,6 +871,10 @@ func Test_visual_block_mode() " reproducible if this operation is performed manually. "call assert_equal(['aaxa', 'bbxb', 'ccxc'], getline(1, '$')) call assert_equal(['aaxa', 'bbba', 'ccca'], getline(1, '$')) + " Repeat the previous test but use 'l' to move the cursor instead of '$' + call setline(1, ['aaa', 'bbb', 'ccc']) + exe "normal! gg2l\2jA\x" + call assert_equal(['aaxa', 'bbxb', 'ccxc'], getline(1, '$')) " Change a characterwise motion to a blockwise motion using CTRL-V %d _ -- cgit From f8b75e582215be5ed07aebb02cdbe69de8cad393 Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Mon, 14 Feb 2022 01:58:47 +0000 Subject: vim-patch:8.2.3073: when cursor is move for block append wrong text is inserted Problem: When cursor is move for block append wrong text is inserted. Solution: Calculate an offset. (Christian Brabandt, closes vim/vim#8433, closes vim/vim#8288) https://github.com/vim/vim/commit/4067bd3604215b48e4b4201e28f9e401b08418e4 --- src/nvim/testdir/test_visual.vim | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'src/nvim/testdir/test_visual.vim') diff --git a/src/nvim/testdir/test_visual.vim b/src/nvim/testdir/test_visual.vim index d05035b4e9..f95801cab5 100644 --- a/src/nvim/testdir/test_visual.vim +++ b/src/nvim/testdir/test_visual.vim @@ -866,11 +866,7 @@ func Test_visual_block_mode() %d _ call setline(1, ['aaa', 'bbb', 'ccc']) exe "normal $\2jA\x" - " BUG: Instead of adding x as the third character in all the three lines, - " 'a' is added in the second and third lines at the end. This bug is not - " reproducible if this operation is performed manually. - "call assert_equal(['aaxa', 'bbxb', 'ccxc'], getline(1, '$')) - call assert_equal(['aaxa', 'bbba', 'ccca'], getline(1, '$')) + call assert_equal(['aaxa', 'bbxb', 'ccxc'], getline(1, '$')) " Repeat the previous test but use 'l' to move the cursor instead of '$' call setline(1, ['aaa', 'bbb', 'ccc']) exe "normal! gg2l\2jA\x" -- cgit From e662d86e8d3198ea77e1a6d0b9be7c09255de520 Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Thu, 3 Feb 2022 01:10:33 +0000 Subject: vim-patch:8.2.4120: block insert goes over the end of the line Problem: Block insert goes over the end of the line. Solution: Handle invalid byte better. Fix inserting the wrong text. https://github.com/vim/vim/commit/9f8c304c8a390ade133bac29963dc8e56ab14cbc --- src/nvim/testdir/test_visual.vim | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/nvim/testdir/test_visual.vim') diff --git a/src/nvim/testdir/test_visual.vim b/src/nvim/testdir/test_visual.vim index f95801cab5..a2c93bd573 100644 --- a/src/nvim/testdir/test_visual.vim +++ b/src/nvim/testdir/test_visual.vim @@ -1242,6 +1242,15 @@ func Test_visual_block_ctrl_w_f() au! BufNew endfunc +func Test_visual_block_append_invalid_char() + " this was going over the end of the line + new + call setline(1, [' let xxx', 'xxxxxˆ', 'xxxxxxxxxxx']) + exe "normal 0\jjA-\" + call assert_equal([' - let xxx', 'xxxxx -ˆ', 'xxxxxxxx-xxx'], getline(1, 3)) + bwipe! +endfunc + func Test_visual_reselect_with_count() " this was causing an illegal memory access let lines =<< trim END -- cgit From afbed8cb75af714a636128c4ad7fb4be6edf7727 Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Thu, 3 Feb 2022 01:22:24 +0000 Subject: vim-patch:8.2.4151: reading beyond the end of a line Problem: Reading beyond the end of a line. Solution: For block insert only use the offset for correcting the length. https://github.com/vim/vim/commit/57df9e8a9f9ae1aafdde9b86b10ad907627a87dc --- src/nvim/testdir/test_visual.vim | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/nvim/testdir/test_visual.vim') diff --git a/src/nvim/testdir/test_visual.vim b/src/nvim/testdir/test_visual.vim index a2c93bd573..edb72c82e3 100644 --- a/src/nvim/testdir/test_visual.vim +++ b/src/nvim/testdir/test_visual.vim @@ -1271,6 +1271,15 @@ func Test_visual_reselect_with_count() call delete('XvisualReselect') endfunc +func Test_visual_block_insert_round_off() + new + " The number of characters are tuned to fill a 4096 byte allocated block, + " so that valgrind reports going over the end. + call setline(1, ['xxxxx', repeat('0', 1350), "\t", repeat('x', 60)]) + exe "normal gg0\GI" .. repeat('0', 1320) .. "\" + bwipe! +endfunc + " this was leaving the end of the Visual area beyond the end of a line func Test_visual_ex_copy_line() new -- cgit