To: vim_dev@googlegroups.com Subject: Patch 7.4.2269 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 7.4.2269 Problem: Using 'hlsearch' highlighting instead of matchpos if there is no search match. Solution: Pass NULL as last item to next_search_hl() when searching for 'hlsearch' match. (Shane Harper, closes #1013) Files: src/screen.c, src/testdir/test_match.vim. *** ../vim-7.4.2268/src/screen.c 2016-08-22 23:04:29.210161667 +0200 --- src/screen.c 2016-08-27 18:31:38.699769756 +0200 *************** *** 3546,3552 **** v = (long)(ptr - line); if (cur != NULL) cur->pos.cur = 0; ! next_search_hl(wp, shl, lnum, (colnr_T)v, cur); /* Need to get the line again, a multi-line regexp may have made it * invalid. */ --- 3546,3553 ---- v = (long)(ptr - line); if (cur != NULL) cur->pos.cur = 0; ! next_search_hl(wp, shl, lnum, (colnr_T)v, ! shl == &search_hl ? NULL : cur); /* Need to get the line again, a multi-line regexp may have made it * invalid. */ *************** *** 3980,3986 **** #ifdef FEAT_CONCEAL prev_syntax_id = 0; #endif ! next_search_hl(wp, shl, lnum, (colnr_T)v, cur); pos_inprogress = cur == NULL || cur->pos.cur == 0 ? FALSE : TRUE; --- 3981,3988 ---- #ifdef FEAT_CONCEAL prev_syntax_id = 0; #endif ! next_search_hl(wp, shl, lnum, (colnr_T)v, ! shl == &search_hl ? NULL : cur); pos_inprogress = cur == NULL || cur->pos.cur == 0 ? FALSE : TRUE; *************** *** 7607,7613 **** while (shl->first_lnum < lnum && (shl->rm.regprog != NULL || (cur != NULL && pos_inprogress))) { ! next_search_hl(wp, shl, shl->first_lnum, (colnr_T)n, cur); pos_inprogress = cur == NULL || cur->pos.cur == 0 ? FALSE : TRUE; if (shl->lnum != 0) --- 7609,7616 ---- while (shl->first_lnum < lnum && (shl->rm.regprog != NULL || (cur != NULL && pos_inprogress))) { ! next_search_hl(wp, shl, shl->first_lnum, (colnr_T)n, ! shl == &search_hl ? NULL : cur); pos_inprogress = cur == NULL || cur->pos.cur == 0 ? FALSE : TRUE; if (shl->lnum != 0) *** ../vim-7.4.2268/src/testdir/test_match.vim 2016-08-18 23:04:44.662592810 +0200 --- src/testdir/test_match.vim 2016-08-27 18:28:13.517514527 +0200 *************** *** 186,189 **** --- 186,216 ---- set hlsearch& endfunc + func Test_matchaddpos_using_negative_priority() + set hlsearch + + call clearmatches() + + call setline(1, 'x') + let @/='x' + redraw! + let search_attr = screenattr(1,1) + + let @/='' + call matchaddpos('Error', [1], 10) + redraw! + let error_attr = screenattr(1,1) + + call setline(2, '-1 match priority') + call matchaddpos('Error', [2], -1) + redraw! + let negative_match_priority_attr = screenattr(2,1) + + call assert_notequal(negative_match_priority_attr, search_attr, "Match with negative priority is incorrectly highlighted with Search highlight.") + call assert_equal(negative_match_priority_attr, error_attr) + + nohl + set hlsearch& + endfunc + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-7.4.2268/src/version.c 2016-08-27 16:26:32.719930990 +0200 --- src/version.c 2016-08-27 18:34:02.318548406 +0200 *************** *** 765,766 **** --- 765,768 ---- { /* Add new patch number below this line */ + /**/ + 2269, /**/ -- From "know your smileys": <<<:-{ Worf (Never smiles anyways, so he's a bad smiley) /// 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 ///