From 423150dfa000be58c5084871e560fc1287839457 Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Sat, 14 Aug 2021 00:35:51 +0100 Subject: vim-patch:8.2.3293: finding completions may cause an endless loop Problem: Finding completions may cause an endless loop. Solution: Use a better way to check coming back where the search started. (Andy Gozas, closes vim/vim#8672, closes vim/vim#8671) https://github.com/vim/vim/commit/6a230c6b32695393785ae64b440ce5f023a22382 --- src/nvim/testdir/test_ins_complete_no_halt.vim | 51 ++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 src/nvim/testdir/test_ins_complete_no_halt.vim (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_ins_complete_no_halt.vim b/src/nvim/testdir/test_ins_complete_no_halt.vim new file mode 100644 index 0000000000..e12925daa9 --- /dev/null +++ b/src/nvim/testdir/test_ins_complete_no_halt.vim @@ -0,0 +1,51 @@ +" Test insert mode completion does not get stuck when looping around. +" In a separate file to avoid the settings to leak to other test cases. + +set complete+=kspell +set completeopt+=menu +set completeopt+=menuone +set completeopt+=noselect +set completeopt+=noinsert +let g:autocompletion = v:true + +func Test_ins_complete_no_halt() + function! OpenCompletion() + if pumvisible() && (g:autocompletion == v:true) + call feedkeys("\\", "i") + return + endif + if ((v:char >= 'a' && v:char <= 'z') || (v:char >= 'A' && v:char <= 'Z')) && (g:autocompletion == v:true) + call feedkeys("\", "i") + redraw + endif + endfunction + + autocmd InsertCharPre * noautocmd call OpenCompletion() + + setlocal spell! spelllang=en_us + + call feedkeys("iauto-complete-halt-test test test test test test test test test test test test test test test test test test test\", "tx!") + call assert_equal(["auto-complete-halt-test test test test test test test test test test test test test test test test test test test"], getline(1, "$")) +endfunc + +func Test_auto_complete_backwards_no_halt() + function! OpenCompletion() + if pumvisible() && (g:autocompletion == v:true) + call feedkeys("\\", "i") + return + endif + if ((v:char >= 'a' && v:char <= 'z') || (v:char >= 'A' && v:char <= 'Z')) && (g:autocompletion == v:true) + call feedkeys("\", "i") + redraw + endif + endfunction + + autocmd InsertCharPre * noautocmd call OpenCompletion() + + setlocal spell! spelllang=en_us + + call feedkeys("iauto-complete-halt-test test test test test test test test test test test test test test test test test test test\", "tx!") + call assert_equal(["auto-complete-halt-test test test test test test test test test test test test test test test test test test test"], getline(1, "$")) +endfunc + +" vim: shiftwidth=2 sts=2 expandtab -- cgit From 2cbbab28d2854cc226ee90be0e9d2527cf53644d Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Fri, 13 Aug 2021 18:20:09 +0100 Subject: vim-patch:8.2.3321: some code is not tested MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Problem: Some code is not tested. Solution: Add some more tests. (Dominique Pellé, closes vim/vim#8735) https://github.com/vim/vim/commit/bd9e7961256ea6a98bd5a7bfe14e32c4c47186e6 Include Test_confirm_write_partial_file() anyway, even though it will not be run. --- src/nvim/testdir/test_excmd.vim | 36 ++++++++++++++++++++++++++++++++++++ src/nvim/testdir/test_writefile.vim | 8 ++++++++ 2 files changed, 44 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_excmd.vim b/src/nvim/testdir/test_excmd.vim index ed2bb2c06b..2d01cbba83 100644 --- a/src/nvim/testdir/test_excmd.vim +++ b/src/nvim/testdir/test_excmd.vim @@ -313,6 +313,42 @@ func Test_confirm_write_ro() call delete('Xconfirm_write_ro') endfunc +func Test_confirm_write_partial_file() + CheckNotGui + CheckRunVimInTerminal + + call writefile(['a', 'b', 'c', 'd'], 'Xwrite_partial') + call writefile(['set nobackup ff=unix cmdheight=2', + \ 'edit Xwrite_partial'], 'Xscript') + let buf = RunVimInTerminal('-S Xscript', {'rows': 20}) + + call term_sendkeys(buf, ":confirm 2,3w\n") + call WaitForAssert({-> assert_match('^Write partial file? *$', + \ term_getline(buf, 19))}, 1000) + call WaitForAssert({-> assert_match('^(Y)es, \[N\]o: *$', + \ term_getline(buf, 20))}, 1000) + call term_sendkeys(buf, 'N') + call WaitForAssert({-> assert_match('.* All$', term_getline(buf, 20))}, 1000) + call assert_equal(['a', 'b', 'c', 'd'], readfile('Xwrite_partial')) + call delete('Xwrite_partial') + + call term_sendkeys(buf, ":confirm 2,3w\n") + call WaitForAssert({-> assert_match('^Write partial file? *$', + \ term_getline(buf, 19))}, 1000) + call WaitForAssert({-> assert_match('^(Y)es, \[N\]o: *$', + \ term_getline(buf, 20))}, 1000) + call term_sendkeys(buf, 'Y') + call WaitForAssert({-> assert_match('^"Xwrite_partial" \[New\] 2L, 4B written *$', + \ term_getline(buf, 19))}, 1000) + call WaitForAssert({-> assert_match('^Press ENTER or type command to continue *$', + \ term_getline(buf, 20))}, 1000) + call assert_equal(['b', 'c'], readfile('Xwrite_partial')) + + call StopVimInTerminal(buf) + call delete('Xwrite_partial') + call delete('Xscript') +endfunc + " Test for the :winsize command func Test_winsize_cmd() call assert_fails('winsize 1', 'E465:') diff --git a/src/nvim/testdir/test_writefile.vim b/src/nvim/testdir/test_writefile.vim index 2504fcb14e..aa7882d129 100644 --- a/src/nvim/testdir/test_writefile.vim +++ b/src/nvim/testdir/test_writefile.vim @@ -191,6 +191,14 @@ func Test_saveas() close! enew | only call delete('Xfile') + + " :saveas should detect and set the file type. + syntax on + saveas! Xsaveas.pl + call assert_equal('perl', &filetype) + syntax off + %bw! + call delete('Xsaveas.pl') endfunc func Test_write_errors() -- cgit From 2ddfd6b9994d1d81b45f38e7e9a2e7ce0333c4e8 Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Fri, 13 Aug 2021 17:00:16 +0100 Subject: vim-patch:8.2.3337: completing "call g:" returns entries with just "g:" Problem: Completing "call g:" returns entries with just "g:". (Naohiro Ono) Solution: Skip empty strings returned by get_user_func_name(). (closes vim/vim#8753) https://github.com/vim/vim/commit/069f90852f1444cac50491c10dfbd339a3f9e0c8 --- src/nvim/testdir/test_cmdline.vim | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim index 34126b49fa..9d5987ba30 100644 --- a/src/nvim/testdir/test_cmdline.vim +++ b/src/nvim/testdir/test_cmdline.vim @@ -602,6 +602,11 @@ func Test_cmdline_complete_user_func() " g: prefix also works call feedkeys(":echo g:Test_cmdline_complete_user_f\\\"\", 'tx') call assert_match('"echo g:Test_cmdline_complete_user_func', @:) + + " using g: prefix does not result in just "g:" matches from a lambda + let Fx = { a -> a } + call feedkeys(":echo g:\\\"\", 'tx') + call assert_match('"echo g:[A-Z]', @:) endfunc func Test_cmdline_complete_user_names() -- cgit From 26b7faf1f21c8583587df2e8ed9c3ac3426f677d Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Sat, 21 Aug 2021 16:13:51 +0100 Subject: vim-patch:8.2.3357: crash when 'virtualedit' is set and window is narrow Problem: Crash when 'virtualedit' is set and window is narrow. () Solution: Check that width is not zero. (closes vim/vim#8767) https://github.com/vim/vim/commit/02f8694a6bd116ab3316add4a7ea6735bf2e8839 --- src/nvim/testdir/test_number.vim | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_number.vim b/src/nvim/testdir/test_number.vim index 92a1bf3c9a..d737ebe9f0 100644 --- a/src/nvim/testdir/test_number.vim +++ b/src/nvim/testdir/test_number.vim @@ -320,4 +320,15 @@ func Test_number_rightleft() bw! endfunc +" This used to cause a divide by zero +func Test_number_no_text_virtual_edit() + vnew + call setline(1, ['line one', 'line two']) + set number virtualedit=all + normal w + 4wincmd | + normal j + bwipe! +endfunc + " vim: shiftwidth=2 sts=2 expandtab -- cgit From ebd035f08b667626eb5f2e02d03628483166abed Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Sat, 21 Aug 2021 16:19:45 +0100 Subject: vim-patch:8.2.3360: user function completion fails with dict function Problem: User function completion fails with dict function. Solution: Do not stop sequencing through the list if user functions when encountering an empty name. (Naohiro Ono, closes vim/vim#8765, closes vim/vim#8774) https://github.com/vim/vim/commit/5aec755b678cfd434b8ea2158d06992f33e1ff80 --- src/nvim/testdir/test_cmdline.vim | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim index 9d5987ba30..1c584aeb81 100644 --- a/src/nvim/testdir/test_cmdline.vim +++ b/src/nvim/testdir/test_cmdline.vim @@ -595,7 +595,7 @@ endfunc func Test_cmdline_complete_user_func() call feedkeys(":func Test_cmdline_complete_user\\\"\", 'tx') - call assert_match('"func Test_cmdline_complete_user', @:) + call assert_match('"func Test_cmdline_complete_user_', @:) call feedkeys(":func s:ScriptL\\\"\", 'tx') call assert_match('"func \d\+_ScriptLocalFunction', @:) @@ -607,6 +607,14 @@ func Test_cmdline_complete_user_func() let Fx = { a -> a } call feedkeys(":echo g:\\\"\", 'tx') call assert_match('"echo g:[A-Z]', @:) + + " existence of script-local dict function does not break user function name + " completion + function s:a_dict_func() dict + endfunction + call feedkeys(":call Test_cmdline_complete_user\\\"\", 'tx') + call assert_match('"call Test_cmdline_complete_user_', @:) + delfunction s:a_dict_func endfunc func Test_cmdline_complete_user_names() -- cgit From d78f06852e78daa4955545576ce5dfad208e4a7b Mon Sep 17 00:00:00 2001 From: Sean Dewar Date: Mon, 23 Aug 2021 20:37:26 +0100 Subject: vim-patch:8.2.3369: auto formatting after "cw" leaves cursor in wrong spot Problem: Auto formatting after "cw" leaves cursor in wrong spot. Solution: Do not auto-format after the delete. (closes vim/vim#8789) https://github.com/vim/vim/commit/6b36d2a16d7931bac82ef8b5654c68ac456b24bf --- src/nvim/testdir/test_textformat.vim | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_textformat.vim b/src/nvim/testdir/test_textformat.vim index 29f0433954..bf0706a0c2 100644 --- a/src/nvim/testdir/test_textformat.vim +++ b/src/nvim/testdir/test_textformat.vim @@ -975,6 +975,13 @@ func Test_fo_a_w() exe "normal f4xx" call assert_equal(['1 2 5 6 7 ', '8 9'], getline(1, 2)) + " using "cw" leaves cursor in right spot + call setline(1, ['Now we g whether that nation, or', + \ 'any nation so conceived and,']) + set fo=tcqa tw=35 + exe "normal 2G0cwx\" + call assert_equal(['Now we g whether that nation, or x', 'nation so conceived and,'], getline(1, 2)) + set tw=0 set fo& %bw! -- cgit