diff src/normal.c @ 27140:a9eeb18e749c v8.2.4099

patch 8.2.4099: Vim9: cannot use Vim9 syntax in mapping Commit: https://github.com/vim/vim/commit/e32c3c462ce9b3163a4a4bffd985897910885d29 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Jan 15 18:26:04 2022 +0000 patch 8.2.4099: Vim9: cannot use Vim9 syntax in mapping Problem: Vim9: cannot use Vim9 syntax in mapping. Solution: Add <ScriptCmd> to use the script context for a command.
author Bram Moolenaar <Bram@vim.org>
date Sat, 15 Jan 2022 19:30:04 +0100
parents b34ddbca305c
children 93d4ee1e6113
line wrap: on
line diff
--- a/src/normal.c
+++ b/src/normal.c
@@ -373,6 +373,7 @@ static const struct nv_cmd
     {K_CURSORHOLD, nv_cursorhold, NV_KEEPREG,		0},
     {K_PS,	nv_edit,	0,			0},
     {K_COMMAND,	nv_colon,	0,			0},
+    {K_SCRIPT_COMMAND, nv_colon, 0,			0},
 };
 
 // Number of commands in nv_cmds[].
@@ -3429,7 +3430,9 @@ nv_colon(cmdarg_T *cap)
 {
     int	old_p_im;
     int	cmd_result;
-    int	is_cmdkey = cap->cmdchar == K_COMMAND;
+    int	is_cmdkey = cap->cmdchar == K_COMMAND
+					   || cap->cmdchar == K_SCRIPT_COMMAND;
+    int	flags;
 
     if (VIsual_active && !is_cmdkey)
 	nv_operator(cap);
@@ -3459,8 +3462,11 @@ nv_colon(cmdarg_T *cap)
 	old_p_im = p_im;
 
 	// get a command line and execute it
-	cmd_result = do_cmdline(NULL, is_cmdkey ? getcmdkeycmd : getexline, NULL,
-			    cap->oap->op_type != OP_NOP ? DOCMD_KEEPLINE : 0);
+	flags = cap->oap->op_type != OP_NOP ? DOCMD_KEEPLINE : 0;
+	if (is_cmdkey)
+	    cmd_result = do_cmdkey_command(cap->cmdchar, flags);
+	else
+	    cmd_result = do_cmdline(NULL, getexline, NULL, flags);
 
 	// If 'insertmode' changed, enter or exit Insert mode
 	if (p_im != old_p_im)