diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-11-07 19:50:51 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2022-11-07 19:52:39 +0800 |
commit | 609c0513cac7898782c55f5fb20275733cc566e9 (patch) | |
tree | 170c9600b5a1aa505d29d24954b1ec0367692cc4 | |
parent | a6f972cb6a5ad47613374570d88df2570ae92b9a (diff) | |
download | rneovim-609c0513cac7898782c55f5fb20275733cc566e9.tar.gz rneovim-609c0513cac7898782c55f5fb20275733cc566e9.tar.bz2 rneovim-609c0513cac7898782c55f5fb20275733cc566e9.zip |
vim-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.
https://github.com/vim/vim/commit/b8e642f7ace5382b4dacb7a8effd86f22b828cc1
Cherry-pick do_autocmd() "eap" argument from patch 8.2.3268.
Co-authored-by: Bram Moolenaar <Bram@vim.org>
-rw-r--r-- | src/nvim/autocmd.c | 4 | ||||
-rw-r--r-- | src/nvim/ex_docmd.c | 2 | ||||
-rw-r--r-- | src/nvim/testdir/test_autocmd.vim | 9 |
3 files changed, 10 insertions, 5 deletions
diff --git a/src/nvim/autocmd.c b/src/nvim/autocmd.c index 5b5ea43d86..9845e6be13 100644 --- a/src/nvim/autocmd.c +++ b/src/nvim/autocmd.c @@ -779,7 +779,7 @@ void au_event_restore(char *old_ei) // :autocmd * *.c show all autocommands for *.c files. // // Mostly a {group} argument can optionally appear before <event>. -void do_autocmd(char *arg_in, int forceit) +void do_autocmd(exarg_T *eap, char *arg_in, int forceit) { char *arg = arg_in; char *envpat = NULL; @@ -790,6 +790,7 @@ void do_autocmd(char *arg_in, int forceit) int group; if (*arg == '|') { + eap->nextcmd = arg + 1; arg = ""; group = AUGROUP_ALL; // no argument, use all groups } else { @@ -806,6 +807,7 @@ void do_autocmd(char *arg_in, int forceit) pat = skipwhite(pat); if (*pat == '|') { + eap->nextcmd = pat + 1; pat = ""; cmd = ""; } else { diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 5bb7cb2da2..992cd9478d 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -4231,7 +4231,7 @@ static void ex_autocmd(exarg_T *eap) secure = 2; eap->errmsg = _(e_curdir); } else if (eap->cmdidx == CMD_autocmd) { - do_autocmd(eap->arg, eap->forceit); + do_autocmd(eap, eap->arg, eap->forceit); } else { do_augroup(eap->arg, eap->forceit); } diff --git a/src/nvim/testdir/test_autocmd.vim b/src/nvim/testdir/test_autocmd.vim index 454fb2bdae..1e9406eb87 100644 --- a/src/nvim/testdir/test_autocmd.vim +++ b/src/nvim/testdir/test_autocmd.vim @@ -481,17 +481,20 @@ endfunc func Test_early_bar() " test that a bar is recognized before the {event} 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(77, done) 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(88, done) " test that a bar is recognized after the {event} 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(99, done) " test that a bar is recognized after the {group} call s:AddAnAutocmd() |