From 73e3669c7a8e2d4f63be17e0f93ee3c641f8806f Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sun, 30 May 2021 21:48:51 -0400 Subject: vim-patch:8.2.2911: pattern "\%V" does not match all of block selection Problem: Pattern "\%V" does not match all of block selection. (Rick Howe) Solution: Use the value of vi_curswant. (closes vim/vim#8285) https://github.com/vim/vim/commit/e71c0ebe2cee4a4916c49e206733200299e4c065 --- src/nvim/testdir/test_search.vim | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_search.vim b/src/nvim/testdir/test_search.vim index b391663e0f..5ba24d047c 100644 --- a/src/nvim/testdir/test_search.vim +++ b/src/nvim/testdir/test_search.vim @@ -824,6 +824,26 @@ func Test_incsearch_search_dump() call delete('Xis_search_script') endfunc +func Test_hlsearch_block_visual_match() + CheckScreendump + + let lines =<< trim END + set hlsearch + call setline(1, ['aa', 'bbbb', 'cccccc']) + END + call writefile(lines, 'Xhlsearch_block') + let buf = RunVimInTerminal('-S Xhlsearch_block', {'rows': 9, 'cols': 60}) + + call term_sendkeys(buf, "G\$kk\") + sleep 100m + call term_sendkeys(buf, "/\\%V\") + sleep 100m + call VerifyScreenDump(buf, 'Test_hlsearch_block_visual_match', {}) + + call StopVimInTerminal(buf) + call delete('Xhlsearch_block') +endfunc + func Test_incsearch_substitute() CheckFunction test_override CheckOption incsearch -- cgit From e39973156173ce8511ff1ae88eec19a3200e08d8 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Sun, 30 May 2021 21:58:16 -0400 Subject: vim-patch:8.2.2914: cannot paste a block without adding padding Problem: Cannot paste a block without adding padding. Solution: Add "zp" and "zP" which paste without adding padding. (Christian Brabandt, closes vim/vim#8289) https://github.com/vim/vim/commit/2fa9384ca1b600b934bec81a72c5fb7ce757503a Cherry-pick Test_normal_z_error() from patch v8.2.0369. --- src/nvim/testdir/test_normal.vim | 6 ++++++ src/nvim/testdir/test_visual.vim | 22 ++++++++++++++++++++++ 2 files changed, 28 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_normal.vim b/src/nvim/testdir/test_normal.vim index 7a846e5ea0..e9de94c0b3 100644 --- a/src/nvim/testdir/test_normal.vim +++ b/src/nvim/testdir/test_normal.vim @@ -512,6 +512,12 @@ func Test_normal14_page_eol() bw! endfunc +" Test for errors with z command +func Test_normal_z_error() + call assert_beeps('normal! z2p') + call assert_beeps('normal! zq') +endfunc + func Test_normal15_z_scroll_vert() " basic test for z commands that scroll the window call Setup_NewWindow() diff --git a/src/nvim/testdir/test_visual.vim b/src/nvim/testdir/test_visual.vim index 73c7960579..d9d10b9681 100644 --- a/src/nvim/testdir/test_visual.vim +++ b/src/nvim/testdir/test_visual.vim @@ -738,4 +738,26 @@ func Test_select_mode_gv() bwipe! endfunc +func Test_visual_put_in_block_using_zp() + new + " paste using zP + call setline(1, ['/path;text', '/path;text', '/path;text', '', + \ '/subdir', + \ '/longsubdir', + \ '/longlongsubdir']) + exe "normal! 5G\2j$y" + norm! 1Gf;zP + call assert_equal(['/path/subdir;text', '/path/longsubdir;text', '/path/longlongsubdir;text'], getline(1, 3)) + %d + " paste using zP + call setline(1, ['/path;text', '/path;text', '/path;text', '', + \ '/subdir', + \ '/longsubdir', + \ '/longlongsubdir']) + exe "normal! 5G\2j$y" + norm! 1Gf;hzp + call assert_equal(['/path/subdir;text', '/path/longsubdir;text', '/path/longlongsubdir;text'], getline(1, 3)) + bwipe! +endfunc + " vim: shiftwidth=2 sts=2 expandtab -- cgit From 2f79caa02dfa59a97403aaa0b5e343e310c0ba14 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Mon, 31 May 2021 21:20:50 -0400 Subject: vim-patch:8.1.2400: test39 is old style Problem: Test39 is old style. Solution: Convert the test cases into new style. (Yegappan Lakshmanan, closes vim/vim#5324) https://github.com/vim/vim/commit/1f3e7d3bf0aa1e015a591ce8f7ee7ab56589b452 --- src/nvim/testdir/test_blockedit.vim | 1 - src/nvim/testdir/test_visual.vim | 156 +++++++++++++++++++++++++++++++++++- 2 files changed, 155 insertions(+), 2 deletions(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_blockedit.vim b/src/nvim/testdir/test_blockedit.vim index 527224ccd2..180524cd73 100644 --- a/src/nvim/testdir/test_blockedit.vim +++ b/src/nvim/testdir/test_blockedit.vim @@ -1,6 +1,5 @@ " Test for block inserting " -" TODO: rewrite test39.in into this new style test func Test_blockinsert_indent() new diff --git a/src/nvim/testdir/test_visual.vim b/src/nvim/testdir/test_visual.vim index d9d10b9681..c879db1542 100644 --- a/src/nvim/testdir/test_visual.vim +++ b/src/nvim/testdir/test_visual.vim @@ -1,4 +1,4 @@ -" Tests for various Visual mode. +" Tests for various Visual modes. func Test_block_shift_multibyte() " Uses double-wide character. @@ -738,6 +738,160 @@ func Test_select_mode_gv() bwipe! endfunc +" Tests for the visual block mode commands +func Test_visual_block_mode() + new + call append(0, '') + call setline(1, ['abcdefghijklm', 'abcdefghijklm', 'abcdefghijklm', + \ 'abcdefghijklm', 'abcdefghijklm']) + call cursor(1, 1) + + " Test shift-right of a block + exe "normal jllll\jj>wll\jlll>" + " Test shift-left of a block + exe "normal G$hhhh\kk<" + " Test block-insert + exe "normal Gkl\kkkIxyz" + " Test block-replace + exe "normal Gllll\kkklllrq" + " Test block-change + exe "normal G$khhh\hhkkcmno" + call assert_equal(['axyzbcdefghijklm', + \ 'axyzqqqq mno ghijklm', + \ 'axyzqqqqef mno ghijklm', + \ 'axyzqqqqefgmnoklm', + \ 'abcdqqqqijklm'], getline(1, 5)) + + bwipe! +endfunc + +" Test block-insert using cursor keys for movement +func Test_visual_block_insert_cursor_keys() + new + call append(0, ['aaaaaa', 'bbbbbb', 'cccccc', 'dddddd']) + call cursor(1, 1) + + exe "norm! l\jjjlllI\\ \" + call assert_equal(['aaa aaa', 'bbb bbb', 'ccc ccc', 'ddd ddd'], + \ getline(1, 4)) + + call deletebufline('', 1, '$') + call setline(1, ['xaaa', 'bbbb', 'cccc', 'dddd']) + call cursor(1, 1) + exe "norm! \jjjI<>\p\" + call assert_equal(['

xaaa', '

bbbb', '

cccc', '

dddd'], + \ getline(1, 4)) + bwipe! +endfunc + +func Test_visual_block_create() + new + call append(0, '') + " Test for Visual block was created with the last $ + call setline(1, ['A23', '4567']) + call cursor(1, 1) + exe "norm! l\j$Aab\" + call assert_equal(['A23ab', '4567ab'], getline(1, 2)) + + " Test for Visual block was created with the middle $ (1) + call deletebufline('', 1, '$') + call setline(1, ['B23', '4567']) + call cursor(1, 1) + exe "norm! l\j$hAab\" + call assert_equal(['B23 ab', '4567ab'], getline(1, 2)) + + " Test for Visual block was created with the middle $ (2) + call deletebufline('', 1, '$') + call setline(1, ['C23', '4567']) + call cursor(1, 1) + exe "norm! l\j$hhAab\" + call assert_equal(['C23ab', '456ab7'], getline(1, 2)) + bwipe! +endfunc + +" Test for Visual block insert when virtualedit=all +func Test_virtualedit_visual_block() + set ve=all + new + call append(0, ["\t\tline1", "\t\tline2", "\t\tline3"]) + call cursor(1, 1) + exe "norm! 07l\jjIx\" + call assert_equal([" x \tline1", + \ " x \tline2", + \ " x \tline3"], getline(1, 3)) + + " Test for Visual block append when virtualedit=all + exe "norm! 012l\jjAx\" + call assert_equal([' x x line1', + \ ' x x line2', + \ ' x x line3'], getline(1, 3)) + set ve= + bwipe! +endfunc + +" Test for changing case +func Test_visual_change_case() + new + " gUe must uppercase a whole word, also when ß changes to SS + exe "normal Gothe youtußeuu end\Ypk0wgUe\r" + " gUfx must uppercase until x, inclusive. + exe "normal O- youßtußexu -\0fogUfx\r" + " VU must uppercase a whole line + exe "normal YpkVU\r" + " same, when it's the last line in the buffer + exe "normal YPGi111\VUddP\r" + " Uppercase two lines + exe "normal Oblah di\rdoh dut\VkUj\r" + " Uppercase part of two lines + exe "normal ddppi333\k0i222\fyllvjfuUk" + call assert_equal(['the YOUTUSSEUU end', '- yOUSSTUSSEXu -', + \ 'THE YOUTUSSEUU END', '111THE YOUTUSSEUU END', 'BLAH DI', 'DOH DUT', + \ '222the yoUTUSSEUU END', '333THE YOUTUßeuu end'], getline(2, '$')) + bwipe! +endfunc + +" Test for Visual replace using Enter or NL +func Test_visual_replace_crnl() + new + exe "normal G3o123456789\e2k05l\2jr\r" + exe "normal G3o98765\e2k02l\2jr\\r\n" + exe "normal G3o123456789\e2k05l\2jr\n" + exe "normal G3o98765\e2k02l\2jr\\n" + call assert_equal(['12345', '789', '12345', '789', '12345', '789', "98\r65", + \ "98\r65", "98\r65", '12345', '789', '12345', '789', '12345', '789', + \ "98\n65", "98\n65", "98\n65"], getline(2, '$')) + bwipe! +endfunc + +func Test_ve_block_curpos() + new + " Test cursor position. When ve=block and Visual block mode and $gj + call append(0, ['12345', '789']) + call cursor(1, 3) + set virtualedit=block + exe "norm! \$gj\" + call assert_equal([0, 2, 4, 0], getpos("'>")) + set virtualedit= + bwipe! +endfunc + +" Test for block_insert when replacing spaces in front of the a with tabs +func Test_block_insert_replace_tabs() + new + set ts=8 sts=4 sw=4 + call append(0, ["#define BO_ALL\t 0x0001", + \ "#define BO_BS\t 0x0002", + \ "#define BO_CRSR\t 0x0004"]) + call cursor(1, 1) + exe "norm! f0\2jI\\" + call assert_equal([ + \ "#define BO_ALL\t\t0x0001", + \ "#define BO_BS\t \t0x0002", + \ "#define BO_CRSR\t \t0x0004", ''], getline(1, '$')) + set ts& sts& sw& + bwipe! +endfunc + func Test_visual_put_in_block_using_zp() new " paste using zP -- cgit From c3ac9c13dffaa79827602536519bc64d65689d05 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Mon, 31 May 2021 21:35:44 -0400 Subject: vim-patch:8.2.2916: operators are not fully tested Problem: Operators are not fully tested. Solution: Add a few more tests. (Yegappan Lakshmanan, closes vim/vim#8290) https://github.com/vim/vim/commit/2ac7184d34cd01e2b76bd1f704fd6a4b4af10239 --- src/nvim/testdir/test_normal.vim | 32 ++++++++++++++ src/nvim/testdir/test_visual.vim | 92 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 124 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_normal.vim b/src/nvim/testdir/test_normal.vim index e9de94c0b3..4a00999c45 100644 --- a/src/nvim/testdir/test_normal.vim +++ b/src/nvim/testdir/test_normal.vim @@ -2883,3 +2883,35 @@ func Test_normal_gk() bw! set cpoptions& number& numberwidth& endfunc + +" Some commands like yy, cc, dd, >>, << and !! accept a count after +" typing the first letter of the command. +func Test_normal_count_after_operator() + new + setlocal shiftwidth=4 tabstop=8 autoindent + call setline(1, ['one', 'two', 'three', 'four', 'five']) + let @a = '' + normal! j"ay4y + call assert_equal("two\nthree\nfour\nfive\n", @a) + normal! 3G>2> + call assert_equal(['one', 'two', ' three', ' four', 'five'], + \ getline(1, '$')) + exe "normal! 3G0c2cred\nblue" + call assert_equal(['one', 'two', ' red', ' blue', 'five'], + \ getline(1, '$')) + exe "normal! gg<8<" + call assert_equal(['one', 'two', 'red', 'blue', 'five'], + \ getline(1, '$')) + exe "normal! ggd3d" + call assert_equal(['blue', 'five'], getline(1, '$')) + call setline(1, range(1, 4)) + call feedkeys("gg!3!\\"\", 'xt') + call assert_equal('".,.+2!', @:) + call feedkeys("gg!1!\\"\", 'xt') + call assert_equal('".!', @:) + call feedkeys("gg!9!\\"\", 'xt') + call assert_equal('".,$!', @:) + bw! +endfunc + +" vim: shiftwidth=2 sts=2 expandtab diff --git a/src/nvim/testdir/test_visual.vim b/src/nvim/testdir/test_visual.vim index c879db1542..21fd57b791 100644 --- a/src/nvim/testdir/test_visual.vim +++ b/src/nvim/testdir/test_visual.vim @@ -762,7 +762,99 @@ func Test_visual_block_mode() \ 'axyzqqqqefgmnoklm', \ 'abcdqqqqijklm'], getline(1, 5)) + " Test from ':help v_b_I_example' + %d _ + setlocal tabstop=8 shiftwidth=4 + let lines =<< trim END + abcdefghijklmnopqrstuvwxyz + abc defghijklmnopqrstuvwxyz + abcdef ghi jklmnopqrstuvwxyz + abcdefghijklmnopqrstuvwxyz + END + call setline(1, lines) + exe "normal ggfo\3jISTRING" + let expected =<< trim END + abcdefghijklmnSTRINGopqrstuvwxyz + abc STRING defghijklmnopqrstuvwxyz + abcdef ghi STRING jklmnopqrstuvwxyz + abcdefghijklmnSTRINGopqrstuvwxyz + END + call assert_equal(expected, getline(1, '$')) + + " Test from ':help v_b_A_example' + %d _ + let lines =<< trim END + abcdefghijklmnopqrstuvwxyz + abc defghijklmnopqrstuvwxyz + abcdef ghi jklmnopqrstuvwxyz + abcdefghijklmnopqrstuvwxyz + END + call setline(1, lines) + exe "normal ggfo\3j$ASTRING" + let expected =<< trim END + abcdefghijklmnopqrstuvwxyzSTRING + abc defghijklmnopqrstuvwxyzSTRING + abcdef ghi jklmnopqrstuvwxyzSTRING + abcdefghijklmnopqrstuvwxyzSTRING + END + call assert_equal(expected, getline(1, '$')) + + " Test from ':help v_b_<_example' + %d _ + let lines =<< trim END + abcdefghijklmnopqrstuvwxyz + abc defghijklmnopqrstuvwxyz + abcdef ghi jklmnopqrstuvwxyz + abcdefghijklmnopqrstuvwxyz + END + call setline(1, lines) + exe "normal ggfo\3j3l<.." + let expected =<< trim END + abcdefghijklmnopqrstuvwxyz + abc defghijklmnopqrstuvwxyz + abcdef ghi jklmnopqrstuvwxyz + abcdefghijklmnopqrstuvwxyz + END + call assert_equal(expected, getline(1, '$')) + + " Test from ':help v_b_>_example' + %d _ + let lines =<< trim END + abcdefghijklmnopqrstuvwxyz + abc defghijklmnopqrstuvwxyz + abcdef ghi jklmnopqrstuvwxyz + abcdefghijklmnopqrstuvwxyz + END + call setline(1, lines) + exe "normal ggfo\3j>.." + let expected =<< trim END + abcdefghijklmn opqrstuvwxyz + abc defghijklmnopqrstuvwxyz + abcdef ghi jklmnopqrstuvwxyz + abcdefghijklmn opqrstuvwxyz + END + call assert_equal(expected, getline(1, '$')) + + " Test from ':help v_b_r_example' + %d _ + let lines =<< trim END + abcdefghijklmnopqrstuvwxyz + abc defghijklmnopqrstuvwxyz + abcdef ghi jklmnopqrstuvwxyz + abcdefghijklmnopqrstuvwxyz + END + call setline(1, lines) + exe "normal ggfo\5l3jrX" + let expected =<< trim END + abcdefghijklmnXXXXXXuvwxyz + abc XXXXXXhijklmnopqrstuvwxyz + abcdef ghi XXXXXX jklmnopqrstuvwxyz + abcdefghijklmnXXXXXXuvwxyz + END + call assert_equal(expected, getline(1, '$')) + bwipe! + set tabstop& shiftwidth& endfunc " Test block-insert using cursor keys for movement -- cgit