]> granicus.if.org Git - vim/commitdiff
patch 8.0.0298: Ex command range with repeated search does not work v8.0.0298
authorBram Moolenaar <Bram@vim.org>
Fri, 3 Feb 2017 20:19:04 +0000 (21:19 +0100)
committerBram Moolenaar <Bram@vim.org>
Fri, 3 Feb 2017 20:19:04 +0000 (21:19 +0100)
Problem:    Ex command range with repeated search does not work. (Bruce
            DeVisser)
Solution:   Skip over \/, \? and \&.

src/ex_docmd.c
src/testdir/test_cmdline.vim
src/version.c

index f93c7665134c919b855030c372b2e4f4f7c414f5..3ee7056c1254b4b9ad3700f24963b79441bd20ee 100644 (file)
@@ -4357,9 +4357,16 @@ skip_range(
 {
     unsigned   delim;
 
-    while (vim_strchr((char_u *)" \t0123456789.$%'/?-+,;", *cmd) != NULL)
+    while (vim_strchr((char_u *)" \t0123456789.$%'/?-+,;\\", *cmd) != NULL)
     {
-       if (*cmd == '\'')
+       if (*cmd == '\\')
+       {
+           if (cmd[1] == '?' || cmd[1] == '/' || cmd[1] == '&')
+               ++cmd;
+           else
+               break;
+       }
+       else if (*cmd == '\'')
        {
            if (*++cmd == NUL && ctx != NULL)
                *ctx = EXPAND_NOTHING;
index fcfce7354d0b0e4d094dbab71280fcda1df59123..aa8fb13c6533b1ca8e1ac7b3c647cb922e12bdea 100644 (file)
@@ -306,3 +306,28 @@ func Test_cmdline_complete_wildoptions()
   call assert_equal(a, b)
   bw!
 endfunc
+
+" using a leading backslash here
+set cpo+=C
+
+func Test_cmdline_search_range()
+  new
+  call setline(1, ['a', 'b', 'c', 'd'])
+  /d
+  1,\/s/b/B/
+  call assert_equal('B', getline(2))
+
+  /a
+  $
+  \?,4s/c/C/
+  call assert_equal('C', getline(3))
+
+  call setline(1, ['a', 'b', 'c', 'd'])
+  %s/c/c/
+  1,\&s/b/B/
+  call assert_equal('B', getline(2))
+
+  bwipe!
+endfunc
+
+set cpo&
index c85a57f6b83831b3b5b208d66f068370e745a6b2..93a59cd6350324758ba7d5209511c714d77d312a 100644 (file)
@@ -764,6 +764,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    298,
 /**/
     297,
 /**/