diff src/vim9execute.c @ 22703:f2bfee4ac356 v8.2.1900

patch 8.2.1900: Vim9: command modifiers do not work Commit: https://github.com/vim/vim/commit/02194d2bd54eacd0b7b9a017a3fe1702ecb80971 Author: Bram Moolenaar <Bram@vim.org> Date: Sat Oct 24 23:08:38 2020 +0200 patch 8.2.1900: Vim9: command modifiers do not work Problem: Vim9: command modifiers do not work. Solution: Make most command modifiers work.
author Bram Moolenaar <Bram@vim.org>
date Sat, 24 Oct 2020 23:15:04 +0200
parents dda110a14be4
children 8968ed4ba4ba
line wrap: on
line diff
--- a/src/vim9execute.c
+++ b/src/vim9execute.c
@@ -832,8 +832,8 @@ call_def_function(
     int		save_suppress_errthrow = suppress_errthrow;
     msglist_T	**saved_msg_list = NULL;
     msglist_T	*private_msg_list = NULL;
-    int		save_msg_silent = -1;
-    int		save_emsg_silent = -1;
+    cmdmod_T	save_cmdmod;
+    int		restore_cmdmod = FALSE;
 
 // Get pointer to item in the stack.
 #define STACK_TV(idx) (((typval_T *)ectx.ec_stack.ga_data) + idx)
@@ -2816,22 +2816,19 @@ call_def_function(
 		}
 		break;
 
-	    case ISN_SILENT:
-		if (save_msg_silent == -1)
-		    save_msg_silent = msg_silent;
-		++msg_silent;
-		if (iptr->isn_arg.number)
-		{
-		    if (save_emsg_silent == -1)
-			save_emsg_silent = emsg_silent;
-		    ++emsg_silent;
-		}
+	    case ISN_CMDMOD:
+		save_cmdmod = cmdmod;
+		restore_cmdmod = TRUE;
+		cmdmod = *iptr->isn_arg.cmdmod.cf_cmdmod;
+		apply_cmdmod(&cmdmod);
 		break;
 
-	    case ISN_UNSILENT:
-		--msg_silent;
-		if (iptr->isn_arg.number)
-		    --emsg_silent;
+	    case ISN_CMDMOD_REV:
+		// filter regprog is owned by the instruction, don't free it
+		cmdmod.cmod_filter_regmatch.regprog = NULL;
+		undo_cmdmod(&cmdmod);
+		cmdmod = save_cmdmod;
+		restore_cmdmod = FALSE;
 		break;
 
 	    case ISN_SHUFFLE:
@@ -2905,10 +2902,12 @@ failed:
     }
     msg_list = saved_msg_list;
 
-    if (save_msg_silent != -1)
-	msg_silent = save_msg_silent;
-    if (save_emsg_silent != -1)
-	emsg_silent = save_emsg_silent;
+    if (restore_cmdmod)
+    {
+	cmdmod.cmod_filter_regmatch.regprog = NULL;
+	undo_cmdmod(&cmdmod);
+	cmdmod = save_cmdmod;
+    }
 
 failed_early:
     // Free all local variables, but not arguments.
@@ -3527,10 +3526,24 @@ ex_disassemble(exarg_T *eap)
 					     (long)iptr->isn_arg.put.put_lnum);
 		break;
 
-	    case ISN_SILENT: smsg("%4d SILENT%s", current,
-				       iptr->isn_arg.number ? "!" : ""); break;
-	    case ISN_UNSILENT: smsg("%4d UNSILENT%s", current,
-				       iptr->isn_arg.number ? "!" : ""); break;
+		// TODO: summarize modifiers
+	    case ISN_CMDMOD:
+		{
+		    char_u  *buf;
+		    int	    len = produce_cmdmods(
+				  NULL, iptr->isn_arg.cmdmod.cf_cmdmod, FALSE);
+
+		    buf = alloc(len + 1);
+		    if (buf != NULL)
+		    {
+			(void)produce_cmdmods(
+				   buf, iptr->isn_arg.cmdmod.cf_cmdmod, FALSE);
+			smsg("%4d CMDMOD %s", current, buf);
+			vim_free(buf);
+		    }
+		    break;
+		}
+	    case ISN_CMDMOD_REV: smsg("%4d CMDMOD_REV", current); break;
 
 	    case ISN_SHUFFLE: smsg("%4d SHUFFLE %d up %d", current,
 					 iptr->isn_arg.shuffle.shfl_item,