]> granicus.if.org Git - vim/commitdiff
patch 8.2.4505: Vim9: outdated "autocmd nested" still works v8.2.4505
authorBram Moolenaar <Bram@vim.org>
Fri, 4 Mar 2022 20:10:38 +0000 (20:10 +0000)
committerBram Moolenaar <Bram@vim.org>
Fri, 4 Mar 2022 20:10:38 +0000 (20:10 +0000)
Problem:    Vim9: outdated "autocmd nested" still works.
Solution:   Do not accept the :autocmd argument "nested" without "++" in Vim9
            script.

src/autocmd.c
src/errors.h
src/testdir/test_autocmd.vim
src/version.c

index 341cf837293f0c023d9c635d4f612c9e07afe2c5..7eb08c85b953b3fac3d735e9fc22fd3c4365db6b 100644 (file)
@@ -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);
                }
index 5ac7b3f3f708337ad30c65b329323724bb8b9d1e..e08186ef2f66343b04e8eb0eae5c9a03b9c50d48 100644 (file)
@@ -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[]
index d3c9b89024dbee329847d3a22c7a7b96f13e1a19..7be0c1815acaadff46fa5700ebe046a2bdd0666e 100644 (file)
@@ -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
index e1ca0d7e8ff7e93d927ec8a440f56243fba4f998..5f703c4dd6227d8f0d21e3ae509b2ec4abdc7f79 100644 (file)
@@ -754,6 +754,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    4505,
 /**/
     4504,
 /**/