diff src/ex_docmd.c @ 24222:a2e6029d354e v8.2.2652

patch 8.2.2652: Vim9: can use command modifier without an effect Commit: https://github.com/vim/vim/commit/fa984418e7becd8e7d6543cd3ea25f605e9ac97f Author: Bram Moolenaar <Bram@vim.org> Date: Thu Mar 25 22:15:28 2021 +0100 patch 8.2.2652: Vim9: can use command modifier without an effect Problem: Vim9: can use command modifier without an effect. Solution: Give an error for a misplaced command modifier. Fix error message number.
author Bram Moolenaar <Bram@vim.org>
date Thu, 25 Mar 2021 22:30:04 +0100
parents 12378fbc99bc
children 0868ac82ef18
line wrap: on
line diff
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -2970,6 +2970,33 @@ parse_command_modifiers(
 }
 
 /*
+ * Return TRUE if "cmod" has anything set.
+ */
+    int
+has_cmdmod(cmdmod_T *cmod)
+{
+    return cmod->cmod_flags != 0
+	    || cmod->cmod_split != 0
+	    || cmod->cmod_verbose != 0
+	    || cmod->cmod_tab != 0
+	    || cmod->cmod_filter_regmatch.regprog != NULL;
+}
+
+/*
+ * If Vim9 script and "cmdmod" has anything set give an error and return TRUE.
+ */
+    int
+cmdmod_error(void)
+{
+    if (in_vim9script() && has_cmdmod(&cmdmod))
+    {
+	emsg(_(e_misplaced_command_modifier));
+	return TRUE;
+    }
+    return FALSE;
+}
+
+/*
  * Apply the command modifiers.  Saves current state in "cmdmod", call
  * undo_cmdmod() later.
  */