patch 8.2.1894: Vim9: command modifiers are not supported
Problem: Vim9: command modifiers are not supported.
Solution: Support "silent" and "silent!".
diff --git a/src/vim9compile.c b/src/vim9compile.c
index 45c35b2..4219577 100644
--- a/src/vim9compile.c
+++ b/src/vim9compile.c
@@ -141,6 +141,8 @@
garray_T ctx_type_stack; // type of each item on the stack
garray_T *ctx_type_list; // list of pointers to allocated types
+
+ int ctx_silent; // set when ISN_SILENT was generated
};
static void delete_def_function_contents(dfunc_T *dfunc);
@@ -1821,6 +1823,40 @@
}
/*
+ * Generate any instructions for side effects of "cmdmod".
+ */
+ static int
+generate_cmdmods(cctx_T *cctx)
+{
+ isn_T *isn;
+
+ // TODO: use more modifiers in the command
+ if (cmdmod.msg_silent || cmdmod.emsg_silent)
+ {
+ if ((isn = generate_instr(cctx, ISN_SILENT)) == NULL)
+ return FAIL;
+ isn->isn_arg.number = cmdmod.emsg_silent;
+ cctx->ctx_silent = cmdmod.emsg_silent ? 2 : 1;
+ }
+ return OK;
+}
+
+ static int
+generate_restore_cmdmods(cctx_T *cctx)
+{
+ isn_T *isn;
+
+ if (cctx->ctx_silent > 0)
+ {
+ if ((isn = generate_instr(cctx, ISN_UNSILENT)) == NULL)
+ return FAIL;
+ isn->isn_arg.number = cctx->ctx_silent == 2;
+ cctx->ctx_silent = 0;
+ }
+ return OK;
+}
+
+/*
* Reserve space for a local variable.
* Return the variable or NULL if it failed.
*/
@@ -7149,7 +7185,8 @@
line = (char_u *)"";
continue;
}
- // TODO: use modifiers in the command
+ generate_cmdmods(&cctx);
+
undo_cmdmod(&ea, save_msg_scroll);
cmdmod = save_cmdmod;
@@ -7461,6 +7498,9 @@
goto erret;
line = skipwhite(line);
+ // Undo any command modifiers.
+ generate_restore_cmdmods(&cctx);
+
if (cctx.ctx_type_stack.ga_len < 0)
{
iemsg("Type stack underflow");
@@ -7767,6 +7807,7 @@
case ISN_PUT:
case ISN_RETURN:
case ISN_SHUFFLE:
+ case ISN_SILENT:
case ISN_SLICE:
case ISN_STORE:
case ISN_STOREDICT:
@@ -7780,6 +7821,7 @@
case ISN_STRSLICE:
case ISN_THROW:
case ISN_TRY:
+ case ISN_UNSILENT:
// nothing allocated
break;
}