0
0
mirror of https://github.com/vim/vim.git synced 2025-09-30 04:44:14 -04:00

patch 8.2.3626: "au! event" cannot be followed by another command

Problem:    "au!" and "au! event" cannot be followed by another command as
            documented.
Solution:   When a bar is found set nextcmd.
This commit is contained in:
Bram Moolenaar
2021-11-20 10:38:25 +00:00
parent 2de9b7c7c8
commit b8e642f7ac
3 changed files with 10 additions and 3 deletions

View File

@@ -845,6 +845,7 @@ do_autocmd(exarg_T *eap, char_u *arg_in, int forceit)
if (*arg == '|') if (*arg == '|')
{ {
eap->nextcmd = arg + 1;
arg = (char_u *)""; arg = (char_u *)"";
group = AUGROUP_ALL; // no argument, use all groups group = AUGROUP_ALL; // no argument, use all groups
} }
@@ -869,6 +870,7 @@ do_autocmd(exarg_T *eap, char_u *arg_in, int forceit)
pat = skipwhite(pat); pat = skipwhite(pat);
if (*pat == '|') if (*pat == '|')
{ {
eap->nextcmd = pat + 1;
pat = (char_u *)""; pat = (char_u *)"";
cmd = (char_u *)""; cmd = (char_u *)"";
} }

View File

@@ -357,17 +357,20 @@ endfunc
func Test_early_bar() func Test_early_bar()
" test that a bar is recognized before the {event} " test that a bar is recognized before the {event}
call s:AddAnAutocmd() call s:AddAnAutocmd()
augroup vimBarTest | au! | augroup END augroup vimBarTest | au! | let done = 77 | augroup END
call assert_equal(1, len(split(execute('au vimBarTest'), "\n"))) call assert_equal(1, len(split(execute('au vimBarTest'), "\n")))
call assert_equal(77, done)
call s:AddAnAutocmd() call s:AddAnAutocmd()
augroup vimBarTest| au!| augroup END augroup vimBarTest| au!| let done = 88 | augroup END
call assert_equal(1, len(split(execute('au vimBarTest'), "\n"))) call assert_equal(1, len(split(execute('au vimBarTest'), "\n")))
call assert_equal(88, done)
" test that a bar is recognized after the {event} " test that a bar is recognized after the {event}
call s:AddAnAutocmd() call s:AddAnAutocmd()
augroup vimBarTest| au!BufReadCmd| augroup END augroup vimBarTest| au!BufReadCmd| let done = 99 | augroup END
call assert_equal(1, len(split(execute('au vimBarTest'), "\n"))) call assert_equal(1, len(split(execute('au vimBarTest'), "\n")))
call assert_equal(99, done)
" test that a bar is recognized after the {group} " test that a bar is recognized after the {group}
call s:AddAnAutocmd() call s:AddAnAutocmd()

View File

@@ -757,6 +757,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
3626,
/**/ /**/
3625, 3625,
/**/ /**/