Skip to content

Commit 3bd8de4

Browse files
committed
patch 8.2.1679: Vim9: ":*" is not recognized as a range
Problem: Vim9: ":*" is not recognized as a range. Solution: Move recognizing "*" into skip_range(). (closes #6838)
1 parent d1f76af commit 3bd8de4

8 files changed

Lines changed: 33 additions & 13 deletions

File tree

src/cmdexpand.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -992,7 +992,7 @@ set_one_cmd_context(
992992
}
993993

994994
// 3. Skip over the range to find the command.
995-
cmd = skip_range(cmd, &xp->xp_context);
995+
cmd = skip_range(cmd, TRUE, &xp->xp_context);
996996
xp->xp_pattern = cmd;
997997
if (*cmd == NUL)
998998
return NULL;

src/ex_docmd.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1779,9 +1779,7 @@ do_one_cmd(
17791779
may_have_range = !vim9script || starts_with_colon;
17801780
if (may_have_range)
17811781
#endif
1782-
ea.cmd = skip_range(ea.cmd, NULL);
1783-
if (*ea.cmd == '*' && vim_strchr(p_cpo, CPO_STAR) == NULL)
1784-
ea.cmd = skipwhite(ea.cmd + 1);
1782+
ea.cmd = skip_range(ea.cmd, TRUE, NULL);
17851783

17861784
#ifdef FEAT_EVAL
17871785
if (vim9script && !starts_with_colon)
@@ -2683,7 +2681,7 @@ parse_command_modifiers(exarg_T *eap, char **errormsg, int skip_only)
26832681
return FAIL;
26842682
}
26852683

2686-
p = skip_range(eap->cmd, NULL);
2684+
p = skip_range(eap->cmd, TRUE, NULL);
26872685
switch (*p)
26882686
{
26892687
// When adding an entry, also modify cmd_exists().
@@ -3534,7 +3532,8 @@ excmd_get_argt(cmdidx_T idx)
35343532
char_u *
35353533
skip_range(
35363534
char_u *cmd,
3537-
int *ctx) // pointer to xp_context or NULL
3535+
int skip_star, // skip "*" used for Visual range
3536+
int *ctx) // pointer to xp_context or NULL
35383537
{
35393538
unsigned delim;
35403539

@@ -3569,6 +3568,10 @@ skip_range(
35693568
while (*cmd == ':')
35703569
cmd = skipwhite(cmd + 1);
35713570

3571+
// Skip "*" used for Visual range.
3572+
if (skip_star && *cmd == '*' && vim_strchr(p_cpo, CPO_STAR) == NULL)
3573+
cmd = skipwhite(cmd + 1);
3574+
35723575
return cmd;
35733576
}
35743577

src/ex_getln.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,12 @@ set_search_match(pos_T *t)
187187
* May change the last search pattern.
188188
*/
189189
static int
190-
do_incsearch_highlighting(int firstc, int *search_delim, incsearch_state_T *is_state,
191-
int *skiplen, int *patlen)
190+
do_incsearch_highlighting(
191+
int firstc,
192+
int *search_delim,
193+
incsearch_state_T *is_state,
194+
int *skiplen,
195+
int *patlen)
192196
{
193197
char_u *cmd;
194198
cmdmod_T save_cmdmod = cmdmod;
@@ -230,7 +234,7 @@ do_incsearch_highlighting(int firstc, int *search_delim, incsearch_state_T *is_s
230234
parse_command_modifiers(&ea, &dummy, TRUE);
231235
cmdmod = save_cmdmod;
232236

233-
cmd = skip_range(ea.cmd, NULL);
237+
cmd = skip_range(ea.cmd, TRUE, NULL);
234238
if (vim_strchr((char_u *)"sgvl", *cmd) == NULL)
235239
goto theend;
236240

src/proto/ex_docmd.pro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ int modifier_len(char_u *cmd);
1616
int cmd_exists(char_u *name);
1717
cmdidx_T excmd_get_cmdidx(char_u *cmd, int len);
1818
long excmd_get_argt(cmdidx_T idx);
19-
char_u *skip_range(char_u *cmd, int *ctx);
19+
char_u *skip_range(char_u *cmd, int skip_star, int *ctx);
2020
void ex_ni(exarg_T *eap);
2121
int expand_filename(exarg_T *eap, char_u **cmdlinep, char **errormsgp);
2222
void separate_nextcmd(exarg_T *eap);

src/testdir/test_vim9_cmd.vim

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,17 @@ def Test_put_command()
330330
bwipe!
331331
enddef
332332

333+
def Test_command_star_range()
334+
new
335+
setline(1, ['xxx foo xxx', 'xxx bar xxx', 'xxx foo xx bar'])
336+
setpos("'<", [0, 1, 0, 0])
337+
setpos("'>", [0, 3, 0, 0])
338+
:*s/\(foo\|bar\)/baz/g
339+
getline(1, 3)->assert_equal(['xxx baz xxx', 'xxx baz xxx', 'xxx baz xx baz'])
340+
341+
bwipe!
342+
enddef
343+
333344

334345

335346
" vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker

src/userfunc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3150,7 +3150,7 @@ def_function(exarg_T *eap, char_u *name_arg)
31503150
}
31513151

31523152
// Check for ":append", ":change", ":insert". Not for :def.
3153-
p = skip_range(p, NULL);
3153+
p = skip_range(p, FALSE, NULL);
31543154
if (eap->cmdidx != CMD_def
31553155
&& ((p[0] == 'a' && (!ASCII_ISALPHA(p[1]) || p[1] == 'p'))
31563156
|| (p[0] == 'c'

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,8 @@ static char *(features[]) =
750750

751751
static int included_patches[] =
752752
{ /* Add new patch number below this line */
753+
/**/
754+
1679,
753755
/**/
754756
1678,
755757
/**/

src/vim9compile.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4276,7 +4276,7 @@ compile_return(char_u *arg, int set_return_type, cctx_T *cctx)
42764276
}
42774277
if (need_type(stack_type, cctx->ctx_ufunc->uf_ret_type, -1,
42784278
cctx, FALSE) == FAIL)
4279-
return NULL;
4279+
return NULL;
42804280
}
42814281
}
42824282
else
@@ -6830,7 +6830,7 @@ compile_def_function(ufunc_T *ufunc, int set_return_type, cctx_T *outer_cctx)
68306830
cmd = ea.cmd;
68316831
if (*cmd != '\'' || starts_with_colon)
68326832
{
6833-
ea.cmd = skip_range(ea.cmd, NULL);
6833+
ea.cmd = skip_range(ea.cmd, TRUE, NULL);
68346834
if (ea.cmd > cmd)
68356835
{
68366836
if (!starts_with_colon)

0 commit comments

Comments
 (0)