To: vim_dev@googlegroups.com Subject: Patch 8.1.0499 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.1.0499 Problem: :2vimgrep causes an ml_get error Solution: Pass tomatch pointer instead of value. (Yegappan Lakshmanan) Files: src/ex_getln.c, src/quickfix.c, src/testdir/test_quickfix.vim *** ../vim-8.1.0498/src/ex_getln.c 2018-09-30 21:43:17.187693348 +0200 --- src/ex_getln.c 2018-10-28 14:27:29.009350706 +0100 *************** *** 483,488 **** --- 483,494 ---- 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 *** ../vim-8.1.0498/src/quickfix.c 2018-10-21 18:47:39.622613657 +0200 --- src/quickfix.c 2018-10-28 14:22:29.387620432 +0100 *************** *** 5217,5223 **** char_u *fname, buf_T *buf, regmmatch_T *regmatch, ! long tomatch, int duplicate_name, int flags) { --- 5217,5223 ---- char_u *fname, buf_T *buf, regmmatch_T *regmatch, ! long *tomatch, int duplicate_name, int flags) { *************** *** 5225,5231 **** long lnum; colnr_T col; ! for (lnum = 1; lnum <= buf->b_ml.ml_line_count && tomatch > 0; ++lnum) { col = 0; while (vim_regexec_multi(regmatch, curwin, buf, lnum, --- 5225,5231 ---- long lnum; colnr_T col; ! for (lnum = 1; lnum <= buf->b_ml.ml_line_count && *tomatch > 0; ++lnum) { col = 0; while (vim_regexec_multi(regmatch, curwin, buf, lnum, *************** *** 5255,5261 **** break; } found_match = TRUE; ! if (--tomatch == 0) break; if ((flags & VGR_GLOBAL) == 0 || regmatch->endpos[0].lnum > 0) --- 5255,5261 ---- break; } found_match = TRUE; ! if (--*tomatch == 0) break; if ((flags & VGR_GLOBAL) == 0 || regmatch->endpos[0].lnum > 0) *************** *** 5464,5470 **** // 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, ®match, ! tomatch, duplicate_name, flags); if (using_dummy) { --- 5464,5470 ---- // 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, ®match, ! &tomatch, duplicate_name, flags); if (using_dummy) { *** ../vim-8.1.0498/src/testdir/test_quickfix.vim 2018-10-21 18:47:39.622613657 +0200 --- src/testdir/test_quickfix.vim 2018-10-28 14:20:59.812305616 +0100 *************** *** 2364,2369 **** --- 2364,2384 ---- 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\", "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) *** ../vim-8.1.0498/src/version.c 2018-10-27 14:27:17.539786667 +0200 --- src/version.c 2018-10-28 14:22:20.871685414 +0100 *************** *** 794,795 **** --- 794,797 ---- { /* Add new patch number below this line */ + /**/ + 499, /**/ -- Bravely bold Sir Robin, rode forth from Camelot, He was not afraid to die, Oh Brave Sir Robin, He was not at all afraid to be killed in nasty ways Brave, brave, brave, brave Sir Robin. "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// Bram Moolenaar -- Bram@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 ///