aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/nvim/screen.c11
-rw-r--r--test/functional/ui/highlight_spec.lua39
2 files changed, 46 insertions, 4 deletions
diff --git a/src/nvim/screen.c b/src/nvim/screen.c
index baec18dd6f..505d04ed56 100644
--- a/src/nvim/screen.c
+++ b/src/nvim/screen.c
@@ -2193,7 +2193,8 @@ win_line (
int prev_c1 = 0; /* first composing char for prev_c */
int did_line_attr = 0;
- bool has_bufhl = false; // this buffer has highlight matches
+ bool search_attr_from_match = false; // if search_attr is from :match
+ bool has_bufhl = false; // this buffer has highlight matches
int bufhl_attr = 0; // attributes desired by bufhl
bufhl_lineinfo_T bufhl_info; // bufhl data for this line
@@ -2625,6 +2626,7 @@ win_line (
if ((long)shl->startcol < v) { // match at leftcol
shl->attr_cur = shl->attr;
search_attr = shl->attr;
+ search_attr_from_match = shl != &search_hl;
}
area_highlighting = true;
}
@@ -2962,6 +2964,7 @@ win_line (
/* Use attributes from match with highest priority among
* 'search_hl' and the match list. */
+ search_attr_from_match = false;
search_attr = search_hl.attr_cur;
cur = wp->w_match_head;
shl_flag = FALSE;
@@ -2974,8 +2977,10 @@ win_line (
shl_flag = TRUE;
} else
shl = &cur->hl;
- if (shl->attr_cur != 0)
+ if (shl->attr_cur != 0) {
search_attr = shl->attr_cur;
+ search_attr_from_match = shl != &search_hl;
+ }
if (shl != &search_hl && cur != NULL)
cur = cur->next;
}
@@ -3711,7 +3716,7 @@ win_line (
}
// Don't override visual selection highlighting.
- if (n_attr > 0 && draw_state == WL_LINE) {
+ if (n_attr > 0 && draw_state == WL_LINE && !search_attr_from_match) {
char_attr = hl_combine_attr(char_attr, extra_attr);
}
diff --git a/test/functional/ui/highlight_spec.lua b/test/functional/ui/highlight_spec.lua
index 945b16ef92..7a1b8c91e7 100644
--- a/test/functional/ui/highlight_spec.lua
+++ b/test/functional/ui/highlight_spec.lua
@@ -401,7 +401,7 @@ describe('guisp (special/undercurl)', function()
end)
end)
-describe("'cursorline' with 'listchars'", function()
+describe("'listchars' highlight", function()
local screen
before_each(function()
@@ -644,4 +644,41 @@ describe("'cursorline' with 'listchars'", function()
|
]])
end)
+
+ it("'cursorline' with :match", function()
+ screen:set_default_attr_ids({
+ [0] = {bold=true, foreground=Screen.colors.Blue},
+ [1] = {background=Screen.colors.Grey90},
+ [2] = {foreground=Screen.colors.Red},
+ [3] = {foreground=Screen.colors.Green1},
+ })
+ execute('highlight clear ModeMsg')
+ execute('highlight SpecialKey guifg=#FF0000')
+ execute('highlight Error guifg=#00FF00')
+ execute('set nowrap')
+ feed('ia \t bc \t <esc>')
+ screen:expect([[
+ a bc ^ |
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ |
+ ]])
+ execute('set listchars=space:.,eol:¬,tab:>-,extends:>,precedes:<,trail:* list')
+ screen:expect([[
+ a{2:.>-----.}bc{2:*>---*^*}{0:¬} |
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ |
+ ]])
+ execute('match Error /\\s\\+$/')
+ screen:expect([[
+ a{2:.>-----.}bc{3:*>---*^*}{0:¬} |
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ |
+ ]])
+ end)
end)