summaryrefslogtreecommitdiffstats
path: root/src/ex_docmd.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-12-01 15:22:56 +0000
committerBram Moolenaar <Bram@vim.org>2021-12-01 15:22:56 +0000
commite4eed8c6db693a9183b776032570ce2f89dcffb6 (patch)
tree8edb253b95ca4b3dcfa430b8c9b3c9151d6257d9 /src/ex_docmd.c
parentf0e496a85a89fb1fd21b6af6363dcfc276331110 (diff)
patch 8.2.3716: Vim9: range without a command is not compiledv8.2.3716
Problem: Vim9: range without a command is not compiled. Solution: Add the ISN_EXECRANGE byte code.
Diffstat (limited to 'src/ex_docmd.c')
-rw-r--r--src/ex_docmd.c87
1 files changed, 50 insertions, 37 deletions
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
index d4863115d8..439a78cedc 100644
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -1977,43 +1977,7 @@ do_one_cmd(
*/
if (ea.skip) // skip this if inside :if
goto doend;
- if ((*ea.cmd == '|' || (exmode_active && ea.line1 != ea.line2))
-#ifdef FEAT_EVAL
- && !vim9script
-#endif
- )
- {
- ea.cmdidx = CMD_print;
- ea.argt = EX_RANGE+EX_COUNT+EX_TRLBAR;
- if ((errormsg = invalid_range(&ea)) == NULL)
- {
- correct_range(&ea);
- ex_print(&ea);
- }
- }
- else if (ea.addr_count != 0)
- {
- if (ea.line2 > curbuf->b_ml.ml_line_count)
- {
- // With '-' in 'cpoptions' a line number past the file is an
- // error, otherwise put it at the end of the file.
- if (vim_strchr(p_cpo, CPO_MINUS) != NULL)
- ea.line2 = -1;
- else
- ea.line2 = curbuf->b_ml.ml_line_count;
- }
-
- if (ea.line2 < 0)
- errormsg = _(e_invalid_range);
- else
- {
- if (ea.line2 == 0)
- curwin->w_cursor.lnum = 1;
- else
- curwin->w_cursor.lnum = ea.line2;
- beginline(BL_SOL | BL_FIX);
- }
- }
+ errormsg = ex_range_without_command(&ea);
goto doend;
}
@@ -2708,6 +2672,55 @@ ex_errmsg(char *msg, char_u *arg)
}
/*
+ * Handle a range without a command.
+ * Returns an error message on failure.
+ */
+ char *
+ex_range_without_command(exarg_T *eap)
+{
+ char *errormsg = NULL;
+
+ if ((*eap->cmd == '|' || (exmode_active && eap->line1 != eap->line2))
+#ifdef FEAT_EVAL
+ && !in_vim9script()
+#endif
+ )
+ {
+ eap->cmdidx = CMD_print;
+ eap->argt = EX_RANGE+EX_COUNT+EX_TRLBAR;
+ if ((errormsg = invalid_range(eap)) == NULL)
+ {
+ correct_range(eap);
+ ex_print(eap);
+ }
+ }
+ else if (eap->addr_count != 0)
+ {
+ if (eap->line2 > curbuf->b_ml.ml_line_count)
+ {
+ // With '-' in 'cpoptions' a line number past the file is an
+ // error, otherwise put it at the end of the file.
+ if (vim_strchr(p_cpo, CPO_MINUS) != NULL)
+ eap->line2 = -1;
+ else
+ eap->line2 = curbuf->b_ml.ml_line_count;
+ }
+
+ if (eap->line2 < 0)
+ errormsg = _(e_invalid_range);
+ else
+ {
+ if (eap->line2 == 0)
+ curwin->w_cursor.lnum = 1;
+ else
+ curwin->w_cursor.lnum = eap->line2;
+ beginline(BL_SOL | BL_FIX);
+ }
+ }
+ return errormsg;
+}
+
+/*
* Check for an Ex command with optional tail.
* If there is a match advance "pp" to the argument and return TRUE.
* If "noparen" is TRUE do not recognize the command followed by "(".