From 9b10b4cc6463d901b893ad2d522c629d066607d5 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 20 Apr 2022 10:26:33 +0800 Subject: vim-patch:8.1.1756: autocommand that splits window messes up window layout Problem: Autocommand that splits window messes up window layout. Solution: Disallow splitting a window while closing one. In ":all" give an error when moving a window will not work. https://github.com/vim/vim/commit/1417c766f55e5959b31da488417b7d9b141404af Expected error number was changed to E242 in Vim in patch 8.2.1183, and patch 8.2.2420 (which has already been ported) made the test no longer throw E249 in Vim, so just use E242 in the test. --- src/nvim/testdir/test_window_cmd.vim | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_window_cmd.vim b/src/nvim/testdir/test_window_cmd.vim index ef6dec580f..798122dc5d 100644 --- a/src/nvim/testdir/test_window_cmd.vim +++ b/src/nvim/testdir/test_window_cmd.vim @@ -513,14 +513,15 @@ func Test_window_colon_command() endfunc func Test_access_freed_mem() + call assert_equal(&columns, winwidth(0)) " This was accessing freed memory (but with what events?) au BufEnter,BufLeave,WinEnter,WinLeave 0 vs xxx arg 0 argadd - all - all + call assert_fails("all", "E242:") au! bwipe xxx + call assert_equal(&columns, winwidth(0)) endfunc func Test_visual_cleared_after_window_split() -- cgit From fa15f2f9380433b4d22387ce313bd4735b960c4e Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 20 Apr 2022 09:18:39 +0800 Subject: vim-patch:8.2.2472: crash when using command line window in an autocommand Problem: Crash when using command line window in an autocommand. (houyunsong) Solution: Save and restore au_new_curbuf. https://github.com/vim/vim/commit/aad5f9d79a2b71e9d2581eace3652be156102b9d Nvim has removed :open, so use :edit in the test instead. --- src/nvim/testdir/test_autocmd.vim | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_autocmd.vim b/src/nvim/testdir/test_autocmd.vim index 228145ec4d..7ad3c8c6ad 100644 --- a/src/nvim/testdir/test_autocmd.vim +++ b/src/nvim/testdir/test_autocmd.vim @@ -2695,9 +2695,9 @@ func Test_autocmd_closes_window() au BufNew,BufWinLeave * e %e file yyy au BufNew,BufWinLeave * ball - call assert_fails('n xxx', 'E143:') + n xxx - bwipe % + %bwipe au! BufNew au! BufWinLeave endfunc @@ -2715,6 +2715,23 @@ func Test_autocmd_quit_psearch() augroup END endfunc +" Fuzzer found some strange combination that caused a crash. +func Test_autocmd_normal_mess() + augroup aucmd_normal_test + au BufLeave,BufWinLeave,BufHidden,BufUnload,BufDelete,BufWipeout * norm 7q/qc + augroup END + " Nvim has removed :open + " o4 + e4 + silent! H + e xx + normal G + + augroup aucmd_normal_test + au! + augroup END +endfunc + func Test_autocmd_closing_cmdwin() au BufWinLeave * nested q call assert_fails("norm 7q?\n", 'E855:') -- cgit From 69ac382a283c92c54fc40b0017688a60fe89a49c Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 20 Apr 2022 09:44:12 +0800 Subject: vim-patch:8.2.2474: using freed memory when window is closed by autocommand Problem: Using freed memory when window is closed by autocommand. (houyunsong) Solution: Check the window pointer is still valid. https://github.com/vim/vim/commit/2c7080bf1ceef4a7779644fd428b2386a0676794 Add missing comment from Vim patch 8.0.1420. Test fails. --- src/nvim/testdir/test_autocmd.vim | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_autocmd.vim b/src/nvim/testdir/test_autocmd.vim index 7ad3c8c6ad..6cfca21f71 100644 --- a/src/nvim/testdir/test_autocmd.vim +++ b/src/nvim/testdir/test_autocmd.vim @@ -2741,6 +2741,19 @@ func Test_autocmd_closing_cmdwin() only endfunc +func Test_autocmd_vimgrep() + augroup aucmd_vimgrep + au QuickfixCmdPre,BufNew,BufDelete,BufReadCmd * sb + au QuickfixCmdPre,BufNew,BufDelete,BufReadCmd * q9 + augroup END + " TODO: if this is executed directly valgrind reports errors + call assert_fails('lv?a?', 'E926:') + + augroup aucmd_vimgrep + au! + augroup END +endfunc + func Test_bufwipeout_changes_window() " This should not crash, but we don't have any expectations about what " happens, changing window in BufWipeout has unpredictable results. -- cgit From 407be5975db5dd63671397676eef0279662c603d Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 20 Apr 2022 10:03:57 +0800 Subject: vim-patch:8.2.2475: autocommand tests hangs on MS-Windows Problem: Autocommand tests hangs on MS-Windows. Solution: Skip one test. https://github.com/vim/vim/commit/dfc3db76b9de217542cc9258301c1b4818a51cd0 --- src/nvim/testdir/test_autocmd.vim | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_autocmd.vim b/src/nvim/testdir/test_autocmd.vim index 6cfca21f71..b80b564470 100644 --- a/src/nvim/testdir/test_autocmd.vim +++ b/src/nvim/testdir/test_autocmd.vim @@ -2717,6 +2717,9 @@ endfunc " Fuzzer found some strange combination that caused a crash. func Test_autocmd_normal_mess() + " TODO: why does this hang on Windows? + CheckNotMSWindows + augroup aucmd_normal_test au BufLeave,BufWinLeave,BufHidden,BufUnload,BufDelete,BufWipeout * norm 7q/qc augroup END -- cgit From 1664e3d4bcc122e6a3b064a3fe20fdc163f6ae9d Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 20 Apr 2022 10:05:02 +0800 Subject: vim-patch:8.2.2476: using freed memory when splitting window while closing buffer Problem: Using freed memory when using an autocommand to split a window while a buffer is being closed. Solution: Disallow splitting when the buffer has b_locked_split set. https://github.com/vim/vim/commit/983d83ff1cd796ff321074335fa53fbe7ac45a46 Put the error message in window.c. Cherry-pick a memory leak fix from Vim patch 8.2.0399. Test still fails. --- src/nvim/testdir/test_autocmd.vim | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_autocmd.vim b/src/nvim/testdir/test_autocmd.vim index b80b564470..7320750cab 100644 --- a/src/nvim/testdir/test_autocmd.vim +++ b/src/nvim/testdir/test_autocmd.vim @@ -2717,17 +2717,14 @@ endfunc " Fuzzer found some strange combination that caused a crash. func Test_autocmd_normal_mess() - " TODO: why does this hang on Windows? - CheckNotMSWindows - augroup aucmd_normal_test au BufLeave,BufWinLeave,BufHidden,BufUnload,BufDelete,BufWipeout * norm 7q/qc augroup END " Nvim has removed :open - " o4 - e4 + " call assert_fails('o4', 'E1159') + call assert_fails('e4', 'E1159') silent! H - e xx + call assert_fails('e xx', 'E1159') normal G augroup aucmd_normal_test @@ -2749,7 +2746,7 @@ func Test_autocmd_vimgrep() au QuickfixCmdPre,BufNew,BufDelete,BufReadCmd * sb au QuickfixCmdPre,BufNew,BufDelete,BufReadCmd * q9 augroup END - " TODO: if this is executed directly valgrind reports errors + %bwipe! call assert_fails('lv?a?', 'E926:') augroup aucmd_vimgrep -- cgit From 69fc23ed9819f2640106ce38613ed6f0962ae926 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 20 Apr 2022 11:09:20 +0800 Subject: vim-patch:8.2.2477: autocommand tests hang on MS-Windows Problem: Autocommand tests hang on MS-Windows. Solution: Skip a couple of tests. Fix file name. https://github.com/vim/vim/commit/dd07c02232e91ee963b91a4477179d4b9548b862 --- src/nvim/testdir/test_autocmd.vim | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_autocmd.vim b/src/nvim/testdir/test_autocmd.vim index 7320750cab..12b6ab26bc 100644 --- a/src/nvim/testdir/test_autocmd.vim +++ b/src/nvim/testdir/test_autocmd.vim @@ -2717,6 +2717,9 @@ endfunc " Fuzzer found some strange combination that caused a crash. func Test_autocmd_normal_mess() + " For unknown reason this hangs on MS-Windows + CheckNotMSWindows + augroup aucmd_normal_test au BufLeave,BufWinLeave,BufHidden,BufUnload,BufDelete,BufWipeout * norm 7q/qc augroup END @@ -2733,6 +2736,9 @@ func Test_autocmd_normal_mess() endfunc func Test_autocmd_closing_cmdwin() + " For unknown reason this hangs on MS-Windows + CheckNotMSWindows + au BufWinLeave * nested q call assert_fails("norm 7q?\n", 'E855:') @@ -2747,7 +2753,7 @@ func Test_autocmd_vimgrep() au QuickfixCmdPre,BufNew,BufDelete,BufReadCmd * q9 augroup END %bwipe! - call assert_fails('lv?a?', 'E926:') + call assert_fails('lv ?a? foo', 'E926:') augroup aucmd_vimgrep au! -- cgit From f531fb97ff5009d2ac279a83da9b9e911c350c89 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 20 Apr 2022 11:11:39 +0800 Subject: vim-patch:8.2.4791: events triggered in different order when reusing buffer Problem: Autocmd events triggered in different order when reusing an empty buffer. Solution: Call buff_freeall() earlier. (Charlie Groves, closes vim/vim#10198) https://github.com/vim/vim/commit/fef4485ef58d5937b170c6dc69431359469fc9cd Test failure becomes very strange. --- src/nvim/testdir/test_autocmd.vim | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_autocmd.vim b/src/nvim/testdir/test_autocmd.vim index 12b6ab26bc..5913032195 100644 --- a/src/nvim/testdir/test_autocmd.vim +++ b/src/nvim/testdir/test_autocmd.vim @@ -2748,9 +2748,10 @@ func Test_autocmd_closing_cmdwin() endfunc func Test_autocmd_vimgrep() + %bwipe! augroup aucmd_vimgrep - au QuickfixCmdPre,BufNew,BufDelete,BufReadCmd * sb - au QuickfixCmdPre,BufNew,BufDelete,BufReadCmd * q9 + au QuickfixCmdPre,BufNew,BufReadCmd * sb + au QuickfixCmdPre,BufNew,BufReadCmd * q9 augroup END %bwipe! call assert_fails('lv ?a? foo', 'E926:') @@ -2795,4 +2796,22 @@ func Test_v_event_readonly() endfunc +func Test_noname_autocmd() + augroup test_noname_autocmd_group + autocmd! + autocmd BufEnter * call add(s:li, ["BufEnter", expand("")]) + autocmd BufDelete * call add(s:li, ["BufDelete", expand("")]) + autocmd BufLeave * call add(s:li, ["BufLeave", expand("")]) + autocmd BufUnload * call add(s:li, ["BufUnload", expand("")]) + autocmd BufWipeout * call add(s:li, ["BufWipeout", expand("")]) + augroup END + + let s:li = [] + edit foo + call assert_equal([['BufUnload', ''], ['BufDelete', ''], ['BufWipeout', ''], ['BufEnter', 'foo']], s:li) + + au! test_noname_autocmd_group + augroup! test_noname_autocmd_group +endfunc + " vim: shiftwidth=2 sts=2 expandtab -- cgit From 5e9afca1c19914cdf6f81685c7950ab180278b1f Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Thu, 21 Apr 2022 18:28:37 +0800 Subject: vim-patch:8.2.4802: test is not cleaned up Problem: Test is not cleaned up. Solution: Make test clean up after itself. Avoid NUL. (closes vim/vim#10233) https://github.com/vim/vim/commit/7851c69a120ea6ce8c122dd7198adbe5aec83ea5 Adapt test_autocmd_vimgrep() to Nvim. --- src/nvim/testdir/test_autocmd.vim | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/nvim/testdir') diff --git a/src/nvim/testdir/test_autocmd.vim b/src/nvim/testdir/test_autocmd.vim index 5913032195..13be82a71d 100644 --- a/src/nvim/testdir/test_autocmd.vim +++ b/src/nvim/testdir/test_autocmd.vim @@ -2713,6 +2713,8 @@ func Test_autocmd_quit_psearch() augroup aucmd_win_test au! augroup END + new + pclose endfunc " Fuzzer found some strange combination that caused a crash. @@ -2748,12 +2750,12 @@ func Test_autocmd_closing_cmdwin() endfunc func Test_autocmd_vimgrep() - %bwipe! augroup aucmd_vimgrep au QuickfixCmdPre,BufNew,BufReadCmd * sb - au QuickfixCmdPre,BufNew,BufReadCmd * q9 + " Nvim makes aucmd_win the last window + " au QuickfixCmdPre,BufNew,BufReadCmd * q9 + au QuickfixCmdPre,BufNew,BufReadCmd * exe 'q' .. (winnr('$') - (win_gettype(winnr('$')) == 'autocmd')) augroup END - %bwipe! call assert_fails('lv ?a? foo', 'E926:') augroup aucmd_vimgrep -- cgit