diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2019-04-06 23:28:05 +0200 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2019-04-06 23:48:26 +0200 |
commit | 3cd9422c4c43fc7f4e6397a2b07a9ab05d4026cf (patch) | |
tree | db605d848740655c3ae48f270b9526a17950df9c /src/nvim/fileio.c | |
parent | 052ced4954075eca360ff7689afea82252f1c599 (diff) | |
download | rneovim-3cd9422c4c43fc7f4e6397a2b07a9ab05d4026cf.tar.gz rneovim-3cd9422c4c43fc7f4e6397a2b07a9ab05d4026cf.tar.bz2 rneovim-3cd9422c4c43fc7f4e6397a2b07a9ab05d4026cf.zip |
vim-patch:8.1.1113: making an autocommand trigger once is not so easy
Problem: Making an autocommand trigger once is not so easy.
Solution: Add the ++once argument. Also add ++nested as an alias for
"nested". (Justin M. Keyes, closes vim/vim#4100)
https://github.com/vim/vim/commit/eb93f3f0e2b2ae65c5c3f55be3e62d64e3066f35
Diffstat (limited to 'src/nvim/fileio.c')
-rw-r--r-- | src/nvim/fileio.c | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index 53b945d983..b2840c9402 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -6061,17 +6061,30 @@ void do_autocmd(char_u *arg_in, int forceit) for (size_t i = 0; i < 2; i++) { if (*cmd != NUL) { // Check for "++once" flag. - if (!once && STRNCMP(cmd, "++once", 6) == 0 && ascii_iswhite(cmd[6])) { + if (STRNCMP(cmd, "++once", 6) == 0 && ascii_iswhite(cmd[6])) { + if (once) { + EMSG2(_(e_duparg2), "++once"); + } once = true; cmd = skipwhite(cmd + 6); } + // Check for "++nested" flag. - if (!nested - && ((STRNCMP(cmd, "++nested", 8) == 0 && ascii_iswhite(cmd[8])) - // Deprecated form (without "++"). - || (STRNCMP(cmd, "nested", 6) == 0 && ascii_iswhite(cmd[6])))) { + if ((STRNCMP(cmd, "++nested", 8) == 0 && ascii_iswhite(cmd[8]))) { + if (nested) { + EMSG2(_(e_duparg2), "++nested"); + } + nested = true; + cmd = skipwhite(cmd + 8); + } + + // Check for the old (deprecated) "nested" flag. + if (STRNCMP(cmd, "nested", 6) == 0 && ascii_iswhite(cmd[6])) { + if (nested) { + EMSG2(_(e_duparg2), "nested"); + } nested = true; - cmd = skipwhite(cmd + ('+' == cmd[0] ? 8 : 6)); + cmd = skipwhite(cmd + 6); } } } |