]> granicus.if.org Git - vim/commitdiff
patch 8.1.0499: :2vimgrep causes an ml_get error v8.1.0499
authorBram Moolenaar <Bram@vim.org>
Sun, 28 Oct 2018 13:36:09 +0000 (14:36 +0100)
committerBram Moolenaar <Bram@vim.org>
Sun, 28 Oct 2018 13:36:09 +0000 (14:36 +0100)
Problem:    :2vimgrep causes an ml_get error
Solution:   Pass tomatch pointer instead of value. (Yegappan Lakshmanan)

src/ex_getln.c
src/quickfix.c
src/testdir/test_quickfix.vim
src/version.c

index e37ebe2c9eecbd5b572949ec01cab6120fd1262a..31e646dd353eaaccc700a4b6f9e932f0fecca7d0 100644 (file)
@@ -483,6 +483,12 @@ may_do_incsearch_highlighting(
     if (search_first_line == 0)
        // start at the original cursor position
        curwin->w_cursor = is_state->search_start;
+    else if (search_first_line > curbuf->b_ml.ml_line_count)
+    {
+       // start after the last line
+       curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count;
+       curwin->w_cursor.col = MAXCOL;
+    }
     else
     {
        // start at the first line in the range
index b899612d874b13af9c350eb96265589c6796e29a..9b1922025a7c47f3edcae6ce526f802775adf70c 100644 (file)
@@ -5217,7 +5217,7 @@ vgr_match_buflines(
        char_u      *fname,
        buf_T       *buf,
        regmmatch_T *regmatch,
-       long        tomatch,
+       long        *tomatch,
        int         duplicate_name,
        int         flags)
 {
@@ -5225,7 +5225,7 @@ vgr_match_buflines(
     long       lnum;
     colnr_T    col;
 
-    for (lnum = 1; lnum <= buf->b_ml.ml_line_count && tomatch > 0; ++lnum)
+    for (lnum = 1; lnum <= buf->b_ml.ml_line_count && *tomatch > 0; ++lnum)
     {
        col = 0;
        while (vim_regexec_multi(regmatch, curwin, buf, lnum,
@@ -5255,7 +5255,7 @@ vgr_match_buflines(
                break;
            }
            found_match = TRUE;
-           if (--tomatch == 0)
+           if (--*tomatch == 0)
                break;
            if ((flags & VGR_GLOBAL) == 0
                    || regmatch->endpos[0].lnum > 0)
@@ -5464,7 +5464,7 @@ ex_vimgrep(exarg_T *eap)
            // Try for a match in all lines of the buffer.
            // For ":1vimgrep" look for first match only.
            found_match = vgr_match_buflines(qi, fname, buf, &regmatch,
-                   tomatch, duplicate_name, flags);
+                   &tomatch, duplicate_name, flags);
 
            if (using_dummy)
            {
index 01a950f34c80d6319e1efe376e4b5d6a60834a30..b779e2806f889b57d7d3df4b543b2a0f885873d0 100644 (file)
@@ -2364,6 +2364,21 @@ func Test_vimgrep()
   call XvimgrepTests('l')
 endfunc
 
+" Test for incsearch highlighting of the :vimgrep pattern
+" This test used to cause "E315: ml_get: invalid lnum" errors.
+func Test_vimgrep_incsearch()
+  enew
+  set incsearch
+  call test_override("char_avail", 1)
+
+  call feedkeys(":2vimgrep assert test_quickfix.vim test_cdo.vim\<CR>", "ntx")
+  let l = getqflist()
+  call assert_equal(2, len(l))
+
+  call test_override("ALL", 0)
+  set noincsearch
+endfunc
+
 func XfreeTests(cchar)
   call s:setup_commands(a:cchar)
 
index c867ecf3907abafb5f4f34c55a961b32cb0fdbb6..b1aa8aa43098df1adf7a4e7bbbb6d5e5a092c06e 100644 (file)
@@ -792,6 +792,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    499,
 /**/
     498,
 /**/