1
0
forked from aniani/vim

patch 8.2.4505: Vim9: outdated "autocmd nested" still works

Problem:    Vim9: outdated "autocmd nested" still works.
Solution:   Do not accept the :autocmd argument "nested" without "++" in Vim9
            script.
This commit is contained in:
Bram Moolenaar
2022-03-04 20:10:38 +00:00
parent 196c3850db
commit f07751457c
4 changed files with 24 additions and 2 deletions

View 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 ((STRNCMP(cmd, "++nested", 8) == 0 && VIM_ISWHITE(cmd[8])))
{ {
if (nested) if (nested)
{
semsg(_(e_duplicate_argument_str), "++nested"); semsg(_(e_duplicate_argument_str), "++nested");
return;
}
nested = TRUE; nested = TRUE;
cmd = skipwhite(cmd + 8); 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 (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) if (nested)
{
semsg(_(e_duplicate_argument_str), "nested"); semsg(_(e_duplicate_argument_str), "nested");
return;
}
nested = TRUE; nested = TRUE;
cmd = skipwhite(cmd + 6); cmd = skipwhite(cmd + 6);
} }

View File

@@ -2786,7 +2786,10 @@ EXTERN char e_this_vim_is_not_compiled_with_float_support[]
# endif # endif
EXTERN char e_missing_argument_type_for_str[] EXTERN char e_missing_argument_type_for_str[]
INIT(= N_("E1077: Missing argument type for %s")); 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[] EXTERN char e_cannot_declare_variable_on_command_line[]
INIT(= N_("E1079: Cannot declare a variable on the command line")); INIT(= N_("E1079: Cannot declare a variable on the command line"));
EXTERN char e_invalid_assignment[] EXTERN char e_invalid_assignment[]

View File

@@ -2116,6 +2116,9 @@ func Test_autocmd_nested()
close close
bwipe! somefile bwipe! somefile
" nested without ++ does not work in Vim9 script
call assert_fails('vim9cmd au WinNew * nested echo fails', 'E1078:')
augroup Testing augroup Testing
au! au!
augroup END augroup END

View File

@@ -754,6 +754,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
4505,
/**/ /**/
4504, 4504,
/**/ /**/