Patch 8.2.2420
Problem: Too many problems with using all autocommand events.
Solution: Disallow defining an autocommand for all events.
Files: src/autocmd.c, src/errors.h, src/testdir/test_autocmd.vim,
src/testdir/test_quickfix.vim, src/testdir/test_window_cmd.vim
*** ../vim-8.2.2419/src/autocmd.c 2020-12-28 18:25:56.796886014 +0100
--- src/autocmd.c 2021-01-28 12:59:39.450938454 +0100
***************
*** 956,966 ****
last_group = AUGROUP_ERROR; // for listing the group name
if (*arg == '*' || *arg == NUL || *arg == '|')
{
! for (event = (event_T)0; (int)event < (int)NUM_EVENTS;
! event = (event_T)((int)event + 1))
! if (do_autocmd_event(event, pat,
! once, nested, cmd, forceit, group) == FAIL)
! break;
}
else
{
--- 956,969 ----
last_group = AUGROUP_ERROR; // for listing the group name
if (*arg == '*' || *arg == NUL || *arg == '|')
{
! if (!forceit && *cmd != NUL)
! emsg(_(e_cannot_define_autocommands_for_all_events));
! else
! for (event = (event_T)0; (int)event < (int)NUM_EVENTS;
! event = (event_T)((int)event + 1))
! if (do_autocmd_event(event, pat,
! once, nested, cmd, forceit, group) == FAIL)
! break;
}
else
{
*** ../vim-8.2.2419/src/errors.h 2021-01-20 21:23:10.709286927 +0100
--- src/errors.h 2021-01-28 12:59:20.591008473 +0100
***************
*** 345,347 ****
--- 345,349 ----
INIT(= N_("E1153: Invalid operation for bool"));
EXTERN char e_divide_by_zero[]
INIT(= N_("E1154: Divide by zero"));
+ EXTERN char e_cannot_define_autocommands_for_all_events[]
+ INIT(= N_("E1155: Cannot define autocommands for ALL events"));
*** ../vim-8.2.2419/src/testdir/test_autocmd.vim 2021-01-28 12:08:28.200619738 +0100
--- src/testdir/test_autocmd.vim 2021-01-28 13:12:14.200298342 +0100
***************
*** 1827,1846 ****
bwipe!
endfunc
! func Test_nocatch_wipe_all_buffers()
! " Real nasty autocommand: wipe all buffers on any event.
! au * * bwipe *
! call assert_fails('next x', ['E94:', 'E937:'])
! bwipe
! au!
! endfunc
!
! func Test_nocatch_wipe_dummy_buffer()
! CheckFeature quickfix
! " Nasty autocommand: wipe buffer on any event.
! au * x bwipe
! call assert_fails('lv½ /x', 'E937:')
! au!
endfunc
function s:Before_test_dirchanged()
--- 1827,1835 ----
bwipe!
endfunc
! func Test_autocommand_all_events()
! call assert_fails('au * * bwipe', 'E1155:')
! call assert_fails('au * x bwipe', 'E1155:')
endfunc
function s:Before_test_dirchanged()
*** ../vim-8.2.2419/src/testdir/test_quickfix.vim 2021-01-03 19:51:01.400063201 +0100
--- src/testdir/test_quickfix.vim 2021-01-28 13:41:50.310248718 +0100
***************
*** 3833,3839 ****
sv Xtest
augroup QF_Test
au!
! au * * bw
augroup END
lbuffer
augroup QF_Test
--- 3833,3839 ----
sv Xtest
augroup QF_Test
au!
! au QuickFixCmdPre,QuickFixCmdPost,BufEnter,BufLeave * bw
augroup END
lbuffer
augroup QF_Test
***************
*** 3845,3851 ****
func Test_lexpr_crash()
augroup QF_Test
au!
! au * * call setloclist(0, [], 'f')
augroup END
lexpr ""
augroup QF_Test
--- 3845,3851 ----
func Test_lexpr_crash()
augroup QF_Test
au!
! au QuickFixCmdPre,QuickFixCmdPost,BufEnter,BufLeave * call setloclist(0, [], 'f')
augroup END
lexpr ""
augroup QF_Test
***************
*** 3880,3886 ****
sv Xtest
augroup QF_Test
au!
! au * * call setloclist(0, [], 'f')
augroup END
lvimgrep quickfix test_quickfix.vim
augroup QF_Test
--- 3880,3886 ----
sv Xtest
augroup QF_Test
au!
! au QuickFixCmdPre,QuickFixCmdPost,BufEnter,BufLeave * call setloclist(0, [], 'f')
augroup END
lvimgrep quickfix test_quickfix.vim
augroup QF_Test
***************
*** 4215,4221 ****
new
new
augroup nasty
! au * * bwipe
augroup END
lbuffer
augroup nasty
--- 4215,4221 ----
new
new
augroup nasty
! au QuickFixCmdPre,QuickFixCmdPost,BufEnter,BufLeave * bwipe
augroup END
lbuffer
augroup nasty
***************
*** 4228,4236 ****
func Xexpr_acmd_freelist(cchar)
call s:setup_commands(a:cchar)
! " This was using freed memory.
augroup nasty
! au * * call g:Xsetlist([], 'f')
augroup END
Xexpr "x"
augroup nasty
--- 4228,4236 ----
func Xexpr_acmd_freelist(cchar)
call s:setup_commands(a:cchar)
! " This was using freed memory (but with what events?)
augroup nasty
! au QuickFixCmdPre,QuickFixCmdPost,BufEnter,BufLeave * call g:Xsetlist([], 'f')
augroup END
Xexpr "x"
augroup nasty
*** ../vim-8.2.2419/src/testdir/test_window_cmd.vim 2021-01-26 22:42:17.694836803 +0100
--- src/testdir/test_window_cmd.vim 2021-01-28 13:43:15.913938265 +0100
***************
*** 567,574 ****
func Test_access_freed_mem()
call assert_equal(&columns, winwidth(0))
! " This was accessing freed memory
! au * 0 vs xxx
arg 0
argadd
call assert_fails("all", "E242:")
--- 567,574 ----
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
call assert_fails("all", "E242:")
*** ../vim-8.2.2419/src/version.c 2021-01-28 12:08:28.204619702 +0100
--- src/version.c 2021-01-28 12:58:37.235169210 +0100
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 2420,
/**/
--
hundred-and-one symptoms of being an internet addict:
255. You work for a newspaper and your editor asks you to write an
article about Internet addiction...in the "first person."
/// Bram Moolenaar -- Br...@Moolenaar.net --
http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features --
http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language --
http://www.Zimbu.org ///
\\\ help me help AIDS victims --
http://ICCF-Holland.org ///