Patch 8.2.1679
Problem: Vim9: ":*" is not recognized as a range.
Solution: Move recognizing "*" into skip_range(). (closes #6838)
Files: src/ex_docmd.c, src/proto/
ex_docmd.pro, src/cmdexpand.c,
src/ex_getln.c, src/userfunc.c, src/vim9compile.c,
src/testdir/test_vim9_cmd.vim
*** ../vim-8.2.1678/src/ex_docmd.c 2020-09-10 19:25:01.612194701 +0200
--- src/ex_docmd.c 2020-09-14 16:35:10.543340682 +0200
***************
*** 1779,1787 ****
may_have_range = !vim9script || starts_with_colon;
if (may_have_range)
#endif
! ea.cmd = skip_range(ea.cmd, NULL);
! if (*ea.cmd == '*' && vim_strchr(p_cpo, CPO_STAR) == NULL)
! ea.cmd = skipwhite(ea.cmd + 1);
#ifdef FEAT_EVAL
if (vim9script && !starts_with_colon)
--- 1779,1785 ----
may_have_range = !vim9script || starts_with_colon;
if (may_have_range)
#endif
! ea.cmd = skip_range(ea.cmd, TRUE, NULL);
#ifdef FEAT_EVAL
if (vim9script && !starts_with_colon)
***************
*** 2683,2689 ****
return FAIL;
}
! p = skip_range(eap->cmd, NULL);
switch (*p)
{
// When adding an entry, also modify cmd_exists().
--- 2681,2687 ----
return FAIL;
}
! p = skip_range(eap->cmd, TRUE, NULL);
switch (*p)
{
// When adding an entry, also modify cmd_exists().
***************
*** 3534,3540 ****
char_u *
skip_range(
char_u *cmd,
! int *ctx) // pointer to xp_context or NULL
{
unsigned delim;
--- 3532,3539 ----
char_u *
skip_range(
char_u *cmd,
! int skip_star, // skip "*" used for Visual range
! int *ctx) // pointer to xp_context or NULL
{
unsigned delim;
***************
*** 3569,3574 ****
--- 3568,3577 ----
while (*cmd == ':')
cmd = skipwhite(cmd + 1);
+ // Skip "*" used for Visual range.
+ if (skip_star && *cmd == '*' && vim_strchr(p_cpo, CPO_STAR) == NULL)
+ cmd = skipwhite(cmd + 1);
+
return cmd;
}
*** ../vim-8.2.1678/src/proto/
ex_docmd.pro 2020-08-23 19:34:44.718827774 +0200
--- src/proto/
ex_docmd.pro 2020-09-14 16:34:37.263458054 +0200
***************
*** 16,22 ****
int cmd_exists(char_u *name);
cmdidx_T excmd_get_cmdidx(char_u *cmd, int len);
long excmd_get_argt(cmdidx_T idx);
! char_u *skip_range(char_u *cmd, int *ctx);
void ex_ni(exarg_T *eap);
int expand_filename(exarg_T *eap, char_u **cmdlinep, char **errormsgp);
void separate_nextcmd(exarg_T *eap);
--- 16,22 ----
int cmd_exists(char_u *name);
cmdidx_T excmd_get_cmdidx(char_u *cmd, int len);
long excmd_get_argt(cmdidx_T idx);
! char_u *skip_range(char_u *cmd, int skip_star, int *ctx);
void ex_ni(exarg_T *eap);
int expand_filename(exarg_T *eap, char_u **cmdlinep, char **errormsgp);
void separate_nextcmd(exarg_T *eap);
*** ../vim-8.2.1678/src/cmdexpand.c 2020-09-05 18:31:30.012880922 +0200
--- src/cmdexpand.c 2020-09-14 16:34:48.299419124 +0200
***************
*** 992,998 ****
}
// 3. Skip over the range to find the command.
! cmd = skip_range(cmd, &xp->xp_context);
xp->xp_pattern = cmd;
if (*cmd == NUL)
return NULL;
--- 992,998 ----
}
// 3. Skip over the range to find the command.
! cmd = skip_range(cmd, TRUE, &xp->xp_context);
xp->xp_pattern = cmd;
if (*cmd == NUL)
return NULL;
*** ../vim-8.2.1678/src/ex_getln.c 2020-09-07 22:05:24.461609737 +0200
--- src/ex_getln.c 2020-09-14 16:35:25.543287784 +0200
***************
*** 187,194 ****
* May change the last search pattern.
*/
static int
! do_incsearch_highlighting(int firstc, int *search_delim, incsearch_state_T *is_state,
! int *skiplen, int *patlen)
{
char_u *cmd;
cmdmod_T save_cmdmod = cmdmod;
--- 187,198 ----
* May change the last search pattern.
*/
static int
! do_incsearch_highlighting(
! int firstc,
! int *search_delim,
! incsearch_state_T *is_state,
! int *skiplen,
! int *patlen)
{
char_u *cmd;
cmdmod_T save_cmdmod = cmdmod;
***************
*** 230,236 ****
parse_command_modifiers(&ea, &dummy, TRUE);
cmdmod = save_cmdmod;
! cmd = skip_range(ea.cmd, NULL);
if (vim_strchr((char_u *)"sgvl", *cmd) == NULL)
goto theend;
--- 234,240 ----
parse_command_modifiers(&ea, &dummy, TRUE);
cmdmod = save_cmdmod;
! cmd = skip_range(ea.cmd, TRUE, NULL);
if (vim_strchr((char_u *)"sgvl", *cmd) == NULL)
goto theend;
*** ../vim-8.2.1678/src/userfunc.c 2020-09-12 18:32:30.683427305 +0200
--- src/userfunc.c 2020-09-14 16:35:40.143236292 +0200
***************
*** 3150,3156 ****
}
// Check for ":append", ":change", ":insert". Not for :def.
! p = skip_range(p, NULL);
if (eap->cmdidx != CMD_def
&& ((p[0] == 'a' && (!ASCII_ISALPHA(p[1]) || p[1] == 'p'))
|| (p[0] == 'c'
--- 3150,3156 ----
}
// Check for ":append", ":change", ":insert". Not for :def.
! p = skip_range(p, FALSE, NULL);
if (eap->cmdidx != CMD_def
&& ((p[0] == 'a' && (!ASCII_ISALPHA(p[1]) || p[1] == 'p'))
|| (p[0] == 'c'
*** ../vim-8.2.1678/src/vim9compile.c 2020-09-12 18:32:30.683427305 +0200
--- src/vim9compile.c 2020-09-14 16:35:55.563181923 +0200
***************
*** 4276,4282 ****
}
if (need_type(stack_type, cctx->ctx_ufunc->uf_ret_type, -1,
cctx, FALSE) == FAIL)
! return NULL;
}
}
else
--- 4276,4282 ----
}
if (need_type(stack_type, cctx->ctx_ufunc->uf_ret_type, -1,
cctx, FALSE) == FAIL)
! return NULL;
}
}
else
***************
*** 6830,6836 ****
cmd = ea.cmd;
if (*cmd != '\'' || starts_with_colon)
{
! ea.cmd = skip_range(ea.cmd, NULL);
if (ea.cmd > cmd)
{
if (!starts_with_colon)
--- 6830,6836 ----
cmd = ea.cmd;
if (*cmd != '\'' || starts_with_colon)
{
! ea.cmd = skip_range(ea.cmd, TRUE, NULL);
if (ea.cmd > cmd)
{
if (!starts_with_colon)
*** ../vim-8.2.1678/src/testdir/test_vim9_cmd.vim 2020-09-08 22:45:31.113504961 +0200
--- src/testdir/test_vim9_cmd.vim 2020-09-14 16:20:31.726463946 +0200
***************
*** 330,335 ****
--- 330,346 ----
bwipe!
enddef
+ def Test_command_star_range()
+ new
+ setline(1, ['xxx foo xxx', 'xxx bar xxx', 'xxx foo xx bar'])
+ setpos("'<", [0, 1, 0, 0])
+ setpos("'>", [0, 3, 0, 0])
+ :*s/\(foo\|bar\)/baz/g
+ getline(1, 3)->assert_equal(['xxx baz xxx', 'xxx baz xxx', 'xxx baz xx baz'])
+
+ bwipe!
+ enddef
+
" vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker
*** ../vim-8.2.1678/src/version.c 2020-09-13 22:37:30.576176018 +0200
--- src/version.c 2020-09-14 16:17:03.695217627 +0200
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 1679,
/**/
--
No man may purchase alcohol without written consent from his wife.
[real standing law in Pennsylvania, United States of America]
/// Bram Moolenaar -- Br...@Moolenaar.net --
http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features --
http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language --
http://www.Zimbu.org ///
\\\ help me help AIDS victims --
http://ICCF-Holland.org ///