From d5b9a7d6e8891c8f456413b86ebfba44f92c713c Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Tue, 11 May 2021 21:00:54 -0400 Subject: vim-patch:8.2.0023: command line editing not sufficiently tested Problem: Command line editing not sufficiently tested. Solution: Add more tests. (Dominique Pelle, closes vim/vim#5374) https://github.com/vim/vim/commit/59cb041d0a56d8555857da7e063ec61504ee1fa7 Ported to commit test_ex_mode.vim for later patches. Test fails because feedkeys() filters out modifier keys on output. --- src/nvim/testdir/test_alot.vim | 1 + src/nvim/testdir/test_cmdline.vim | 48 +++++++++++++++++++++++---------- src/nvim/testdir/test_ex_mode.vim | 56 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 91 insertions(+), 14 deletions(-) create mode 100644 src/nvim/testdir/test_ex_mode.vim (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_alot.vim b/src/nvim/testdir/test_alot.vim index e50602ccad..b5c50b5894 100644 --- a/src/nvim/testdir/test_alot.vim +++ b/src/nvim/testdir/test_alot.vim @@ -10,6 +10,7 @@ source test_cursor_func.vim source test_ex_equal.vim source test_ex_undo.vim source test_ex_z.vim +source test_ex_mode.vim source test_execute_func.vim source test_expand_func.vim source test_feedkeys.vim diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim index a1968807ac..5c4f68c700 100644 --- a/src/nvim/testdir/test_cmdline.vim +++ b/src/nvim/testdir/test_cmdline.vim @@ -477,7 +477,7 @@ func Test_expand_star_star() call delete('a', 'rf') endfunc -func Test_paste_in_cmdline() +func Test_cmdline_paste() let @a = "def" call feedkeys(":abc \a ghi\\"\", 'tx') call assert_equal('"abc def ghi', @:) @@ -517,18 +517,38 @@ func Test_paste_in_cmdline() bwipe! endfunc -func Test_remove_char_in_cmdline() - call feedkeys(":abc def\\\\"\", 'tx') - call assert_equal('"abc ef', @:) +func Test_cmdline_remove_char() + let encoding_save = &encoding + + " for e in ['utf8', 'latin1'] + for e in ['utf8'] + exe 'set encoding=' . e + + call feedkeys(":abc def\\\\"\", 'tx') + call assert_equal('"abc ef', @:, e) + + call feedkeys(":abc def\\\\"\", 'tx') + call assert_equal('"abcdef', @:) + + call feedkeys(":abc def ghi\\\\"\", 'tx') + call assert_equal('"abc ghi', @:, e) - call feedkeys(":abc def\\\\"\", 'tx') - call assert_equal('"abcdef', @:) + call feedkeys(":abc def\\\\"\", 'tx') + call assert_equal('"def', @:, e) + endfor + + let &encoding = encoding_save +endfunc - call feedkeys(":abc def ghi\\\\"\", 'tx') - call assert_equal('"abc ghi', @:) +func Test_cmdline_keymap_ctrl_hat() + if !has('keymap') + return + endif - call feedkeys(":abc def\\\\"\", 'tx') - call assert_equal('"def', @:) + set keymap=esperanto + call feedkeys(":\"Jxauxdo \Jxauxdo \Jxauxdo\", 'tx') + call assert_equal('"Jxauxdo Ĵaŭdo Jxauxdo', @:) + set keymap= endfunc func Test_illegal_address1() @@ -863,20 +883,20 @@ func Test_cmdline_overstrike() " Test overstrike in the middle of the command line. call feedkeys(":\"01234\\\ab\\cd\", 'xt') - call assert_equal('"0ab1cd4', @:) + call assert_equal('"0ab1cd4', @:, e) " Test overstrike going beyond end of command line. call feedkeys(":\"01234\\\ab\\cdefgh\", 'xt') - call assert_equal('"0ab1cdefgh', @:) + call assert_equal('"0ab1cdefgh', @:, e) " Test toggling insert/overstrike a few times. call feedkeys(":\"01234\\ab\\cd\\ef\", 'xt') - call assert_equal('"ab0cd3ef4', @:) + call assert_equal('"ab0cd3ef4', @:, e) endfor " Test overstrike with multi-byte characters. call feedkeys(":\"テキストエディタ\\\ab\\cd\", 'xt') - call assert_equal('"テabキcdエディタ', @:) + call assert_equal('"テabキcdエディタ', @:, e) let &encoding = encoding_save endfunc diff --git a/src/nvim/testdir/test_ex_mode.vim b/src/nvim/testdir/test_ex_mode.vim new file mode 100644 index 0000000000..87c23a2fe8 --- /dev/null +++ b/src/nvim/testdir/test_ex_mode.vim @@ -0,0 +1,56 @@ +" Test editing line in Ex mode (see :help Q and :help gQ). + +" Helper function to test editing line in Q Ex mode +func Ex_Q(cmd) + " Is there a simpler way to test editing Ex line? + call feedkeys("Q" + \ .. "let s:test_ex =<< END\" + \ .. a:cmd .. "\" + \ .. "END\" + \ .. "visual\", 'tx') + return s:test_ex[0] +endfunc + +" Helper function to test editing line in gQ Ex mode +func Ex_gQ(cmd) + call feedkeys("gQ" .. a:cmd .. "\\"\", 'tx') + let ret = @:[1:] " Remove leading quote. + call feedkeys("visual\", 'tx') + return ret +endfunc + +" Helper function to test editing line with both Q and gQ Ex mode. +func Ex(cmd) + return [Ex_Q(a:cmd), Ex_gQ(a:cmd)] +endfunc + +" Test editing line in Ex mode (both Q and gQ) +func Test_ex_mode() + throw 'skipped: TODO: ' + let encoding_save = &encoding + set sw=2 + + " for e in ['utf8', 'latin1'] + for e in ['utf8'] + exe 'set encoding=' . e + + call assert_equal(['bar', 'bar'], Ex("foo bar\bar"), e) + call assert_equal(["1\2", "1\2"], Ex("1\\2"), e) + call assert_equal(["1\2\3", '213'], Ex("1\2\3"), e) + call assert_equal(['0123', '2013'], Ex("01\2\3"), e) + call assert_equal(['0123', '0213'], Ex("01\2\3"), e) + call assert_equal(['01234', '0342'], Ex("012\\\3\4"), e) + call assert_equal(["foo bar\", 'foo '], Ex("foo bar\"), e) + call assert_equal(['foo', 'foo'], Ex("fooba\\"), e) + call assert_equal(["foo\tbar", 'foobar'], Ex("foo\bar"), e) + call assert_equal(["abbrev\t", 'abbreviate'], Ex("abbrev\"), e) + call assert_equal([' 1', "1\\"], Ex("1\\"), e) + call assert_equal([' 1', "1\\"], Ex("1\\\"), e) + call assert_equal([' foo', ' foo'], Ex(" foo\"), e) + call assert_equal(['foo', ' foo0'], Ex(" foo0\"), e) + call assert_equal(['foo', ' foo^'], Ex(" foo^\"), e) + endfor + + set sw& + let &encoding = encoding_save +endfunc -- cgit From 73392909006de74e628323cde915b107244a247b Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Tue, 11 May 2021 21:10:14 -0400 Subject: vim-patch:8.2.1000: get error when leaving Ex mode with :visual Problem: Get error when leaving Ex mode with :visual and a CmdLineEnter autocommand was used. Solution: Reset ex_pressedreturn. (closes vim/vim#6293) https://github.com/vim/vim/commit/158ea175a99fc23eae1b0a5ee9a81cdd973854a6 --- src/nvim/testdir/test_ex_mode.vim | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_ex_mode.vim b/src/nvim/testdir/test_ex_mode.vim index 87c23a2fe8..f70cb261e0 100644 --- a/src/nvim/testdir/test_ex_mode.vim +++ b/src/nvim/testdir/test_ex_mode.vim @@ -54,3 +54,29 @@ func Test_ex_mode() set sw& let &encoding = encoding_save endfunc + +func Test_ex_mode_errors() + " Not allowed to enter ex mode when text is locked + au InsertCharPre normal! gQ + let caught_e523 = 0 + try + call feedkeys("ix\", 'xt') + catch /^Vim\%((\a\+)\)\=:E523/ " catch E523 + let caught_e523 = 1 + endtry + call assert_equal(1, caught_e523) + au! InsertCharPre + + new + au CmdLineEnter * call ExEnterFunc() + func ExEnterFunc() + + endfunc + call feedkeys("gQvi\r", 'xt') + + au! CmdLineEnter + delfunc ExEnterFunc + quit +endfunc + +" vim: shiftwidth=2 sts=2 expandtab -- cgit From f54a938271a4006a05638956a46e0bbe114eedf7 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Tue, 11 May 2021 21:20:32 -0400 Subject: vim-patch:8.2.1059: crash when using :tabonly in an autocommand Problem: Crash when using :tabonly in an autocommand. (Yegappan Lakshmanan) Solution: Do not allow the autocommand window to be closed. https://github.com/vim/vim/commit/cf8441704d6e517bda1899f4afa82c6b4eecbaec E813 error message does not mention 'popup' window because Neovim floating window are regular windows, unlike Vim popups. https://github.com/neovim/neovim/pull/14532#discussion_r631731829 --- src/nvim/testdir/test_autocmd.vim | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_autocmd.vim b/src/nvim/testdir/test_autocmd.vim index 5611560b1b..fb3aa2b3b0 100644 --- a/src/nvim/testdir/test_autocmd.vim +++ b/src/nvim/testdir/test_autocmd.vim @@ -1949,6 +1949,26 @@ func Test_autocmd_window() %bw! endfunc +" Test for trying to close the tab that has the temporary window for exeucing +" an autocmd. +func Test_close_autocmd_tab() + edit one.txt + tabnew two.txt + augroup aucmd_win_test + au! + au BufEnter * if expand('') == 'one.txt' | tabfirst | tabonly | endif + augroup END + + call assert_fails('doautoall BufEnter', 'E813:') + + tabonly + augroup aucmd_win_test + au! + augroup END + augroup! aucmd_win_test + %bwipe! +endfunc + func Test_autocmd_closes_window() au BufNew,BufWinLeave * e %e file yyy -- cgit From f98433d82a340008fdc51c2093e74400e71101dc Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Tue, 11 May 2021 22:17:12 -0400 Subject: vim-patch:8.2.2354: crash with a weird combination of autocommands Problem: Crash with a weird combination of autocommands. Solution: Increment b_nwindows when needed. (closes vim/vim#7674) https://github.com/vim/vim/commit/797e63b9f2baa1853e7063aac478d663cd02f207 --- src/nvim/testdir/test_autocmd.vim | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_autocmd.vim b/src/nvim/testdir/test_autocmd.vim index fb3aa2b3b0..a2aa1c32c5 100644 --- a/src/nvim/testdir/test_autocmd.vim +++ b/src/nvim/testdir/test_autocmd.vim @@ -452,6 +452,27 @@ func Test_autocmd_bufwipe_in_SessLoadPost() endfor endfunc +" Using :blast and :ball for many events caused a crash, because b_nwindows was +" not incremented correctly. +func Test_autocmd_blast_badd() + let content =<< trim [CODE] + au BufNew,BufAdd,BufWinEnter,BufEnter,BufLeave,BufWinLeave,BufUnload,VimEnter foo* blast + edit foo1 + au BufNew,BufAdd,BufWinEnter,BufEnter,BufLeave,BufWinLeave,BufUnload,VimEnter foo* ball + edit foo2 + call writefile(['OK'], 'Xerrors') + qall + [CODE] + + call writefile(content, 'XblastBall') + call system(GetVimCommand() .. ' --clean -S XblastBall') + " call assert_match('OK', readfile('Xerrors')->join()) + call assert_match('OK', join(readfile('Xerrors'))) + + call delete('XblastBall') + call delete('Xerrors') +endfunc + " SEGV occurs in older versions. func Test_autocmd_bufwipe_in_SessLoadPost2() tabnew -- cgit From 1ca89a60d8b5027f7d4491d9da749c2184194f27 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Wed, 12 May 2021 02:50:51 -0400 Subject: vim-patch:8.2.2359: strange test failure with MS-Windows Problem: Strange test failure with MS-Windows. Solution: Skip the system() call for now. https://github.com/vim/vim/commit/e2924328c165f1fc549f91bf212c93c87bb1d9ed --- src/nvim/testdir/test_autocmd.vim | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_autocmd.vim b/src/nvim/testdir/test_autocmd.vim index a2aa1c32c5..c2abf71a95 100644 --- a/src/nvim/testdir/test_autocmd.vim +++ b/src/nvim/testdir/test_autocmd.vim @@ -455,6 +455,14 @@ endfunc " Using :blast and :ball for many events caused a crash, because b_nwindows was " not incremented correctly. func Test_autocmd_blast_badd() + " The system() here causes SetChangeMarks() to fail, when run in the GUI + " under Windows. No idea why. Happens with any external command, not + " related to the actual test. + " TODO: find the cause + if has('win32') + throw 'Skipped: calling system() causes problems' + endif + let content =<< trim [CODE] au BufNew,BufAdd,BufWinEnter,BufEnter,BufLeave,BufWinLeave,BufUnload,VimEnter foo* blast edit foo1 -- cgit From 3f9fa730ceb059ab94dcd20b8f323faca1417110 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Wed, 12 May 2021 02:51:43 -0400 Subject: vim-patch:8.2.2419: autocmd test was failing on MS-Windows with GUI Problem: Autocmd test was failing on MS-Windows with GUI. Solution: Remove stray feedkeys(). https://github.com/vim/vim/commit/d697ddea1466d877a79f8c56d46361dc54e9baef --- src/nvim/testdir/test_autocmd.vim | 9 --------- 1 file changed, 9 deletions(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_autocmd.vim b/src/nvim/testdir/test_autocmd.vim index c2abf71a95..e0a04c94f8 100644 --- a/src/nvim/testdir/test_autocmd.vim +++ b/src/nvim/testdir/test_autocmd.vim @@ -190,7 +190,6 @@ func Test_autocmd_bufunload_avoiding_SEGV_02() normal! i1 call assert_fails('edit a.txt', 'E517:') - call feedkeys("\") autocmd! test_autocmd_bufunload augroup! test_autocmd_bufunload @@ -455,14 +454,6 @@ endfunc " Using :blast and :ball for many events caused a crash, because b_nwindows was " not incremented correctly. func Test_autocmd_blast_badd() - " The system() here causes SetChangeMarks() to fail, when run in the GUI - " under Windows. No idea why. Happens with any external command, not - " related to the actual test. - " TODO: find the cause - if has('win32') - throw 'Skipped: calling system() causes problems' - endif - let content =<< trim [CODE] au BufNew,BufAdd,BufWinEnter,BufEnter,BufLeave,BufWinLeave,BufUnload,VimEnter foo* blast edit foo1 -- cgit From 07f6f12cf529da403ccb1f3df48d266fa2008db7 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Tue, 11 May 2021 22:18:48 -0400 Subject: vim-patch:8.2.2433: opening cmdline window gives error in BufLeave autocommand Problem: Opening cmdline window gives error in BufLeave autocommand. Solution: Reset cmdwin_type when triggering the autocommand. https://github.com/vim/vim/commit/b63f3ca66db20f7b135aae706d36be538f91f8cc --- src/nvim/testdir/test_cmdline.vim | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim index 5c4f68c700..b521a193c4 100644 --- a/src/nvim/testdir/test_cmdline.vim +++ b/src/nvim/testdir/test_cmdline.vim @@ -1005,6 +1005,25 @@ func Test_buffers_lastused() bwipeout bufc endfunc +" Test for CmdwinEnter autocmd +func Test_cmdwin_autocmd() + CheckFeature cmdwin + + augroup CmdWin + au! + autocmd BufLeave * if &buftype == '' | update | endif + autocmd CmdwinEnter * startinsert + augroup END + + call assert_fails('call feedkeys("q:xyz\", "xt")', 'E492:') + call assert_equal('xyz', @:) + + augroup CmdWin + au! + augroup END + augroup! CmdWin +endfunc + func Test_cmdlineclear_tabenter() " See test/functional/legacy/cmdline_spec.lua CheckScreendump -- cgit From c9195a1273159bfd227bfa9a7b407888d0d18110 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Tue, 11 May 2021 22:27:21 -0400 Subject: vim-patch:8.2.2473: crash when leaving command line window triggers autocommand Problem: Crash when leaving command line window triggers autocommand. (houyunsong) Solution: Make sure not to close the current window or buffer. https://github.com/vim/vim/commit/8c6951fa2836a1ae3257770e7b927a9380439912 N/A patches for version.c: vim-patch:8.2.2414: using freed memory when closing the cmdline window Problem: Using freed memory when closing the cmdline window. Solution: Check the window is still valid. https://github.com/vim/vim/commit/b7e2670b6a1de02c772af5097ba24f2a15b26eec --- src/nvim/testdir/test_autocmd.vim | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_autocmd.vim b/src/nvim/testdir/test_autocmd.vim index e0a04c94f8..bb84fa498e 100644 --- a/src/nvim/testdir/test_autocmd.vim +++ b/src/nvim/testdir/test_autocmd.vim @@ -2000,4 +2000,13 @@ func Test_autocmd_closes_window() au! BufWinLeave endfunc +func Test_autocmd_closing_cmdwin() + au BufWinLeave * nested q + call assert_fails("norm 7q?\n", 'E855:') + + au! BufWinLeave + new + only +endfunc + " vim: shiftwidth=2 sts=2 expandtab -- cgit From 520b925627604a5c3030d4e59dc2caa2f6501736 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Thu, 13 May 2021 23:56:34 -0400 Subject: vim-patch:8.2.2850: recalling commands from history is not tested Problem: Recalling commands from history is not tested. Solution: Add tests. (closes vim/vim#8194) https://github.com/vim/vim/commit/71c6f7a665eb467054fbf319989d97c252af28d2 --- src/nvim/testdir/test_cmdline.vim | 48 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim index b521a193c4..34126b49fa 100644 --- a/src/nvim/testdir/test_cmdline.vim +++ b/src/nvim/testdir/test_cmdline.vim @@ -1072,4 +1072,52 @@ func Test_read_shellcmd() endif endfunc +" Test for recalling newer or older cmdline from history with , , +" , , , , , or . +func Test_recalling_cmdline() + CheckFeature cmdline_hist + + let g:cmdlines = [] + cnoremap (save-cmdline) let g:cmdlines += [getcmdline()] + + let histories = [ + \ {'name': 'cmd', 'enter': ':', 'exit': "\"}, + \ {'name': 'search', 'enter': '/', 'exit': "\"}, + \ {'name': 'expr', 'enter': ":\=", 'exit': "\\"}, + \ {'name': 'input', 'enter': ":call input('')\", 'exit': "\"}, + "\ TODO: {'name': 'debug', ...} + \] + let keypairs = [ + \ {'older': "\", 'newer': "\", 'prefixmatch': v:true}, + \ {'older': "\", 'newer': "\", 'prefixmatch': v:false}, + \ {'older': "\", 'newer': "\", 'prefixmatch': v:false}, + \ {'older': "\", 'newer': "\", 'prefixmatch': v:false}, + \] + let prefix = 'vi' + for h in histories + call histadd(h.name, 'vim') + call histadd(h.name, 'virtue') + call histadd(h.name, 'Virgo') + call histadd(h.name, 'vogue') + call histadd(h.name, 'emacs') + for k in keypairs + let g:cmdlines = [] + let keyseqs = h.enter + \ .. prefix + \ .. repeat(k.older .. "\(save-cmdline)", 2) + \ .. repeat(k.newer .. "\(save-cmdline)", 2) + \ .. h.exit + call feedkeys(keyseqs, 'xt') + call histdel(h.name, -1) " delete the history added by feedkeys above + let expect = k.prefixmatch + \ ? ['virtue', 'vim', 'virtue', prefix] + \ : ['emacs', 'vogue', 'emacs', prefix] + call assert_equal(expect, g:cmdlines) + endfor + endfor + + unlet g:cmdlines + cunmap (save-cmdline) +endfunc + " vim: shiftwidth=2 sts=2 expandtab -- cgit