]> granicus.if.org Git - vim/commitdiff
patch 7.4.2269 v7.4.2269
authorBram Moolenaar <Bram@vim.org>
Sat, 27 Aug 2016 16:34:29 +0000 (18:34 +0200)
committerBram Moolenaar <Bram@vim.org>
Sat, 27 Aug 2016 16:34:29 +0000 (18:34 +0200)
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)

src/screen.c
src/testdir/test_match.vim
src/version.c

index b580aee78a8e09ef6873bb205dcbf4cfb4298573..ab1e85f6d4ca364f941e010e57f28775fbb03fe8 100644 (file)
@@ -3546,7 +3546,8 @@ win_line(
        v = (long)(ptr - line);
        if (cur != NULL)
            cur->pos.cur = 0;
-       next_search_hl(wp, shl, lnum, (colnr_T)v, cur);
+       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,7 +3981,8 @@ win_line(
 #ifdef FEAT_CONCEAL
                            prev_syntax_id = 0;
 #endif
-                           next_search_hl(wp, shl, lnum, (colnr_T)v, cur);
+                           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,7 +7609,8 @@ prepare_search_hl(win_T *wp, linenr_T lnum)
            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);
+               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)
index 000893673b82976fcf22c0d2cb90f4f6a8f1fe82..9ac1db157f9986dc85f85fe3121390e620e679ec 100644 (file)
@@ -186,4 +186,31 @@ func Test_matchaddpos()
   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
index 529b255cc9f5ed9da26b750299570f82b57ab757..289474ba825ef2f3caad36bf8776e0670511128e 100644 (file)
@@ -763,6 +763,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2269,
 /**/
     2268,
 /**/