highlight: :match should override 'list' (#6343)

Closes #4946
This commit is contained in:
Yichao Zhou 2017-03-26 04:04:20 -07:00 committed by Justin M. Keyes
parent cf202b74db
commit 43a99f77a8
2 changed files with 46 additions and 4 deletions

View File

@ -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);
}

View File

@ -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)