diff options
author | bfredl <bjorn.linse@gmail.com> | 2022-05-07 09:46:06 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-07 09:46:06 +0200 |
commit | 6c39f9d4277778d8532bf8c308d59470a03ee2b9 (patch) | |
tree | 2b4d674d8e6924f25c1c2e61282bf742beb43351 /src/nvim/ex_docmd.c | |
parent | cd8edb551b6eed3424c2525e50d2a5eecbfe7ccf (diff) | |
parent | 14f3383c0da1413a5ae82feb19ac89f01d4b9aad (diff) | |
download | rneovim-6c39f9d4277778d8532bf8c308d59470a03ee2b9.tar.gz rneovim-6c39f9d4277778d8532bf8c308d59470a03ee2b9.tar.bz2 rneovim-6c39f9d4277778d8532bf8c308d59470a03ee2b9.zip |
Merge pull request #18457 from famiu/feat/api/nvim_parse_cmd
fix(api): make `nvim_parse_cmd` work correctly with both range and count
Diffstat (limited to 'src/nvim/ex_docmd.c')
-rw-r--r-- | src/nvim/ex_docmd.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 116264b4c1..df78fe9c34 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -1320,7 +1320,7 @@ static void parse_register(exarg_T *eap) } } -static int parse_count(exarg_T *eap, char **errormsg) +static int parse_count(exarg_T *eap, char **errormsg, bool validate) { // Check for a count. When accepting a EX_BUFNAME, don't use "123foo" as a // count, it's a buffer name. @@ -1348,7 +1348,7 @@ static int parse_count(exarg_T *eap, char **errormsg) eap->line2 += n - 1; eap->addr_count++; // Be vi compatible: no error message for out of range. - if (eap->line2 > curbuf->b_ml.ml_line_count) { + if (validate && eap->line2 > curbuf->b_ml.ml_line_count) { eap->line2 = curbuf->b_ml.ml_line_count; } } @@ -1426,7 +1426,7 @@ bool parse_cmdline(char *cmdline, exarg_T *eap, CmdParseInfo *cmdinfo, char **er } p = find_command(eap, NULL); - // Set command attribute type and parse command range + // Set command address type and parse command range set_cmd_addr_type(eap, (char_u *)p); eap->cmd = cmd; if (parse_cmd_address(eap, errormsg, false) == FAIL) { @@ -1499,7 +1499,7 @@ bool parse_cmdline(char *cmdline, exarg_T *eap, CmdParseInfo *cmdinfo, char **er // Parse register and count parse_register(eap); - if (parse_count(eap, errormsg) == FAIL) { + if (parse_count(eap, errormsg, false) == FAIL) { return false; } @@ -1981,7 +1981,7 @@ static char *do_one_cmd(char **cmdlinep, int flags, cstack_T *cstack, LineGetter // Parse register and count parse_register(&ea); - if (parse_count(&ea, &errormsg) == FAIL) { + if (parse_count(&ea, &errormsg, true) == FAIL) { goto doend; } |