autocmd: rename "once" => "-once" #9713

- Rename "nested" to "-nested", but continue to support "nested" for
  backwards-compatibility.
- Allow any order: "-once -nested" or "-nested -once".

ref https://github.com/neovim/neovim/pull/9706#issuecomment-471295747
This commit is contained in:
Justin M. Keyes
2019-03-11 21:01:47 +01:00
committed by GitHub
parent 3b63374b33
commit 9312e2d06a
6 changed files with 45 additions and 42 deletions

View File

@@ -6047,20 +6047,23 @@ void do_autocmd(char_u *arg_in, int forceit)
}
}
// Check for "once" flag.
cmd = skipwhite(cmd);
if (*cmd != NUL && STRNCMP(cmd, "once", 4) == 0
&& ascii_iswhite(cmd[4])) {
once = true;
cmd = skipwhite(cmd + 4);
}
// Check for "nested" flag.
cmd = skipwhite(cmd);
if (*cmd != NUL && STRNCMP(cmd, "nested", 6) == 0
&& ascii_iswhite(cmd[6])) {
nested = true;
cmd = skipwhite(cmd + 6);
for (size_t i = 0; i < 2; i++) {
if (*cmd != NUL) {
// Check for "-once" flag.
if (!once && STRNCMP(cmd, "-once", 5) == 0 && ascii_iswhite(cmd[5])) {
once = true;
cmd = skipwhite(cmd + 5);
}
// Check for "-nested" flag.
if (!nested
&& ((STRNCMP(cmd, "-nested", 7) == 0 && ascii_iswhite(cmd[7]))
// Deprecated form (without "-").
|| (STRNCMP(cmd, "nested", 6) == 0 && ascii_iswhite(cmd[6])))) {
nested = true;
cmd = skipwhite(cmd + ('-' == cmd[0] ? 7 : 6));
}
}
}
// Find the start of the commands.