aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-07-13 09:15:16 +0800
committerzeertzjq <zeertzjq@outlook.com>2024-07-14 06:12:42 +0800
commit88c698083aa0819fb19c3129b81c6f291a5bf568 (patch)
treeefdc687bd81611dfbd165f18e86a1f8f9a8baee8
parent3700d94c6fa3c6e2a58fc02414e4ca32b823214f (diff)
downloadrneovim-88c698083aa0819fb19c3129b81c6f291a5bf568.tar.gz
rneovim-88c698083aa0819fb19c3129b81c6f291a5bf568.tar.bz2
rneovim-88c698083aa0819fb19c3129b81c6f291a5bf568.zip
vim-patch:8.2.3716: Vim9: range without a command is not compiled
Problem: Vim9: range without a command is not compiled. Solution: Add the ISN_EXECRANGE byte code. https://github.com/vim/vim/commit/e4eed8c6db693a9183b776032570ce2f89dcffb6 Co-authored-by: Bram Moolenaar <Bram@vim.org>
-rw-r--r--src/nvim/ex_docmd.c56
1 files changed, 33 insertions, 23 deletions
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index 44a9c07ec8..2495b673e4 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -2079,29 +2079,7 @@ static char *do_one_cmd(char **cmdlinep, int flags, cstack_T *cstack, LineGetter
if (ea.skip) { // skip this if inside :if
goto doend;
}
- if (*ea.cmd == '|' || (exmode_active && ea.line1 != ea.line2)) {
- 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) {
- ea.line2 = curbuf->b_ml.ml_line_count;
- }
-
- if (ea.line2 < 0) {
- errormsg = _(e_invrange);
- } 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;
}
@@ -2447,6 +2425,38 @@ char *ex_errmsg(const char *const msg, const char *const arg)
return ex_error_buf;
}
+/// Handle a range without a command.
+/// Returns an error message on failure.
+static char *ex_range_without_command(exarg_T *eap)
+{
+ char *errormsg = NULL;
+
+ if (*eap->cmd == '|' || (exmode_active && eap->line1 != eap->line2)) {
+ 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) {
+ eap->line2 = curbuf->b_ml.ml_line_count;
+ }
+
+ if (eap->line2 < 0) {
+ errormsg = _(e_invrange);
+ } else {
+ if (eap->line2 == 0) {
+ curwin->w_cursor.lnum = 1;
+ } else {
+ curwin->w_cursor.lnum = eap->line2;
+ }
+ beginline(BL_SOL | BL_FIX);
+ }
+ }
+ return errormsg;
+}
+
/// Parse and skip over command modifiers:
/// - update eap->cmd
/// - store flags in "cmod".