diff src/autocmd.c @ 27960:be693de40634 v8.2.4505

patch 8.2.4505: Vim9: outdated "autocmd nested" still works Commit: https://github.com/vim/vim/commit/f07751457c39a645009c17cd837131f6bcdd7d55 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Mar 4 20:10:38 2022 +0000 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.
author Bram Moolenaar <Bram@vim.org>
date Fri, 04 Mar 2022 21:15:02 +0100
parents c1d1639b52dd
children e466fdbe0699
line wrap: on
line diff
--- a/src/autocmd.c
+++ b/src/autocmd.c
@@ -921,16 +921,30 @@ do_autocmd(exarg_T *eap, char_u *arg_in,
 		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);
 		}