diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-11-25 20:12:11 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-11-25 20:12:11 +0100 |
commit | 47a2abf0bc3c3dac0433754ad0365ebad152df8c (patch) | |
tree | f8062b3e3006cb009b8b578fe0769e7992829283 /src/ex_docmd.c | |
parent | 34c54eb6cbda5dbc14376c8b1c62ad11d4852793 (diff) |
patch 8.2.2052: Vim9: "edit +4 fname" gives an errorv8.2.2052
Problem: Vim9: "edit +4 fname" gives an error. (Naruhiko Nishino)
Solution: Allow using a range in the +cmd argument. (closes #7364)
Diffstat (limited to 'src/ex_docmd.c')
-rw-r--r-- | src/ex_docmd.c | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/src/ex_docmd.c b/src/ex_docmd.c index 44e113d53b..582791af63 100644 --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -595,6 +595,17 @@ do_cmdline_cmd(char_u *cmd) } /* + * Execute the "+cmd" argument of "edit +cmd fname" and the like. + * This allows for using a range without ":" in Vim9 script. + */ + int +do_cmd_argument(char_u *cmd) +{ + return do_cmdline(cmd, NULL, NULL, + DOCMD_VERBOSE|DOCMD_NOWAIT|DOCMD_KEYTYPED|DOCMD_RANGEOK); +} + +/* * do_cmdline(): execute one Ex command line * * 1. Execute "cmdline" when it is not NULL. @@ -989,7 +1000,7 @@ do_cmdline( * "cmdline_copy" can change, e.g. for '%' and '#' expansion. */ ++recursive; - next_cmdline = do_one_cmd(&cmdline_copy, flags & DOCMD_VERBOSE, + next_cmdline = do_one_cmd(&cmdline_copy, flags, #ifdef FEAT_EVAL &cstack, #endif @@ -1685,7 +1696,8 @@ comment_start(char_u *p, int starts_with_colon UNUSED) /* * Execute one Ex command. * - * If 'sourcing' is TRUE, the command will be included in the error message. + * If "flags" has DOCMD_VERBOSE, the command will be included in the error + * message. * * 1. skip comment lines and leading space * 2. handle command modifiers @@ -1708,7 +1720,7 @@ comment_start(char_u *p, int starts_with_colon UNUSED) static char_u * do_one_cmd( char_u **cmdlinep, - int sourcing, + int flags, #ifdef FEAT_EVAL cstack_T *cstack, #endif @@ -1731,6 +1743,7 @@ do_one_cmd( int vim9script = in_vim9script(); int did_set_expr_line = FALSE; #endif + int sourcing = flags & DOCMD_VERBOSE; CLEAR_FIELD(ea); ea.line1 = 1; @@ -1794,7 +1807,7 @@ do_one_cmd( #ifdef FEAT_EVAL // In Vim9 script a colon is required before the range. This may also be // after command modifiers. - if (vim9script) + if (vim9script && (flags & DOCMD_RANGEOK) == 0) { may_have_range = FALSE; for (p = ea.cmd; p >= *cmdlinep; --p) @@ -5009,7 +5022,7 @@ ex_buffer(exarg_T *eap) else goto_buffer(eap, DOBUF_FIRST, FORWARD, (int)eap->line2); if (eap->do_ecmd_cmd != NULL) - do_cmdline_cmd(eap->do_ecmd_cmd); + do_cmd_argument(eap->do_ecmd_cmd); } } @@ -5022,7 +5035,7 @@ ex_bmodified(exarg_T *eap) { goto_buffer(eap, DOBUF_MOD, FORWARD, (int)eap->line2); if (eap->do_ecmd_cmd != NULL) - do_cmdline_cmd(eap->do_ecmd_cmd); + do_cmd_argument(eap->do_ecmd_cmd); } /* @@ -5037,7 +5050,7 @@ ex_bnext(exarg_T *eap) goto_buffer(eap, DOBUF_CURRENT, FORWARD, (int)eap->line2); if (eap->do_ecmd_cmd != NULL) - do_cmdline_cmd(eap->do_ecmd_cmd); + do_cmd_argument(eap->do_ecmd_cmd); } /* @@ -5054,7 +5067,7 @@ ex_bprevious(exarg_T *eap) goto_buffer(eap, DOBUF_CURRENT, BACKWARD, (int)eap->line2); if (eap->do_ecmd_cmd != NULL) - do_cmdline_cmd(eap->do_ecmd_cmd); + do_cmd_argument(eap->do_ecmd_cmd); } /* @@ -5071,7 +5084,7 @@ ex_brewind(exarg_T *eap) goto_buffer(eap, DOBUF_FIRST, FORWARD, 0); if (eap->do_ecmd_cmd != NULL) - do_cmdline_cmd(eap->do_ecmd_cmd); + do_cmd_argument(eap->do_ecmd_cmd); } /* @@ -5086,7 +5099,7 @@ ex_blast(exarg_T *eap) goto_buffer(eap, DOBUF_LAST, BACKWARD, 0); if (eap->do_ecmd_cmd != NULL) - do_cmdline_cmd(eap->do_ecmd_cmd); + do_cmd_argument(eap->do_ecmd_cmd); } /* @@ -6680,7 +6693,7 @@ do_exedit( else { if (eap->do_ecmd_cmd != NULL) - do_cmdline_cmd(eap->do_ecmd_cmd); + do_cmd_argument(eap->do_ecmd_cmd); #ifdef FEAT_TITLE n = curwin->w_arg_idx_invalid; #endif |