summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-03-04 20:10:38 +0000
committerBram Moolenaar <Bram@vim.org>2022-03-04 20:10:38 +0000
commitf07751457c39a645009c17cd837131f6bcdd7d55 (patch)
tree119f5f4f97b44fa75496ec1d690c855bc16af8c3
parent196c3850dbe95247f7aa1b0000a5cae625a99ef2 (diff)
downloadvim-git-8.2.4505.tar.gz
patch 8.2.4505: Vim9: outdated "autocmd nested" still worksv8.2.4505
Problem: Vim9: outdated "autocmd nested" still works. Solution: Do not accept the :autocmd argument "nested" without "++" in Vim9 script.
-rw-r--r--src/autocmd.c16
-rw-r--r--src/errors.h5
-rw-r--r--src/testdir/test_autocmd.vim3
-rw-r--r--src/version.c2
4 files changed, 24 insertions, 2 deletions
diff --git a/src/autocmd.c b/src/autocmd.c
index 341cf8372..7eb08c85b 100644
--- a/src/autocmd.c
+++ b/src/autocmd.c
@@ -921,16 +921,30 @@ do_autocmd(exarg_T *eap, char_u *arg_in, int forceit)
if ((STRNCMP(cmd, "++nested", 8) == 0 && VIM_ISWHITE(cmd[8])))
{
if (nested)
+ {
semsg(_(e_duplicate_argument_str), "++nested");
+ return;
+ }
nested = TRUE;
cmd = skipwhite(cmd + 8);
}
- // Check for the old "nested" flag.
+ // Check for the old "nested" flag in legacy script.
if (STRNCMP(cmd, "nested", 6) == 0 && VIM_ISWHITE(cmd[6]))
{
+ if (in_vim9script())
+ {
+ // If there ever is a :nested command this error should
+ // be removed and "nested" accepted as the start of the
+ // command.
+ emsg(_(e_invalid_command_nested_did_you_mean_plusplus_nested));
+ return;
+ }
if (nested)
+ {
semsg(_(e_duplicate_argument_str), "nested");
+ return;
+ }
nested = TRUE;
cmd = skipwhite(cmd + 6);
}
diff --git a/src/errors.h b/src/errors.h
index 5ac7b3f3f..e08186ef2 100644
--- a/src/errors.h
+++ b/src/errors.h
@@ -2786,7 +2786,10 @@ EXTERN char e_this_vim_is_not_compiled_with_float_support[]
# endif
EXTERN char e_missing_argument_type_for_str[]
INIT(= N_("E1077: Missing argument type for %s"));
-// E1078 unused
+#endif
+EXTERN char e_invalid_command_nested_did_you_mean_plusplus_nested[]
+ INIT(= N_("E1078: Invalid command \"nested\", did you mean \"++nested\"?"));
+#ifdef FEAT_EVAL
EXTERN char e_cannot_declare_variable_on_command_line[]
INIT(= N_("E1079: Cannot declare a variable on the command line"));
EXTERN char e_invalid_assignment[]
diff --git a/src/testdir/test_autocmd.vim b/src/testdir/test_autocmd.vim
index d3c9b8902..7be0c1815 100644
--- a/src/testdir/test_autocmd.vim
+++ b/src/testdir/test_autocmd.vim
@@ -2116,6 +2116,9 @@ func Test_autocmd_nested()
close
bwipe! somefile
+ " nested without ++ does not work in Vim9 script
+ call assert_fails('vim9cmd au WinNew * nested echo fails', 'E1078:')
+
augroup Testing
au!
augroup END
diff --git a/src/version.c b/src/version.c
index e1ca0d7e8..5f703c4dd 100644
--- a/src/version.c
+++ b/src/version.c
@@ -755,6 +755,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 4505,
+/**/
4504,
/**/
4503,