aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/nvim/screen.c9
-rw-r--r--src/nvim/testdir/test_match.vim27
2 files changed, 33 insertions, 3 deletions
diff --git a/src/nvim/screen.c b/src/nvim/screen.c
index c5fe5e8b05..2b6005b484 100644
--- a/src/nvim/screen.c
+++ b/src/nvim/screen.c
@@ -2597,7 +2597,8 @@ win_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.
@@ -2926,7 +2927,8 @@ win_line (
shl->attr_cur = 0;
prev_syntax_id = 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);
pos_inprogress = !(cur == NULL || cur->pos.cur == 0);
/* Need to get the line again, a multi-line regexp
@@ -5562,7 +5564,8 @@ static void prepare_search_hl(win_T *wp, linenr_T lnum)
n = 0;
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);
if (shl->lnum != 0) {
shl->first_lnum = shl->lnum
diff --git a/src/nvim/testdir/test_match.vim b/src/nvim/testdir/test_match.vim
index 67f3ea7373..ce06143bad 100644
--- a/src/nvim/testdir/test_match.vim
+++ b/src/nvim/testdir/test_match.vim
@@ -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: et ts=2 sw=2