Skip to content

Commit cbf20fb

Browse files
committed
patch 8.0.0298: Ex command range with repeated search does not work
Problem: Ex command range with repeated search does not work. (Bruce DeVisser) Solution: Skip over \/, \? and \&.
1 parent 03ff9bc commit cbf20fb

3 files changed

Lines changed: 36 additions & 2 deletions

File tree

src/ex_docmd.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4357,9 +4357,16 @@ skip_range(
43574357
{
43584358
unsigned delim;
43594359

4360-
while (vim_strchr((char_u *)" \t0123456789.$%'/?-+,;", *cmd) != NULL)
4360+
while (vim_strchr((char_u *)" \t0123456789.$%'/?-+,;\\", *cmd) != NULL)
43614361
{
4362-
if (*cmd == '\'')
4362+
if (*cmd == '\\')
4363+
{
4364+
if (cmd[1] == '?' || cmd[1] == '/' || cmd[1] == '&')
4365+
++cmd;
4366+
else
4367+
break;
4368+
}
4369+
else if (*cmd == '\'')
43634370
{
43644371
if (*++cmd == NUL && ctx != NULL)
43654372
*ctx = EXPAND_NOTHING;

src/testdir/test_cmdline.vim

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,3 +306,28 @@ func Test_cmdline_complete_wildoptions()
306306
call assert_equal(a, b)
307307
bw!
308308
endfunc
309+
310+
" using a leading backslash here
311+
set cpo+=C
312+
313+
func Test_cmdline_search_range()
314+
new
315+
call setline(1, ['a', 'b', 'c', 'd'])
316+
/d
317+
1,\/s/b/B/
318+
call assert_equal('B', getline(2))
319+
320+
/a
321+
$
322+
\?,4s/c/C/
323+
call assert_equal('C', getline(3))
324+
325+
call setline(1, ['a', 'b', 'c', 'd'])
326+
%s/c/c/
327+
1,\&s/b/B/
328+
call assert_equal('B', getline(2))
329+
330+
bwipe!
331+
endfunc
332+
333+
set cpo&

src/version.c

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

765765
static int included_patches[] =
766766
{ /* Add new patch number below this line */
767+
/**/
768+
298,
767769
/**/
768770
297,
769771
/**/

0 commit comments

Comments
 (0)