options: winhighlight: fix incorrect string equality test

This commit is contained in:
Björn Linse 2020-01-28 12:49:29 +01:00
parent e956ea7672
commit bfe84adb5a
2 changed files with 44 additions and 1 deletions

View File

@ -3842,7 +3842,8 @@ static bool parse_winhl_opt(win_T *wp)
w_hl_id_normal = hl_id;
} else {
for (hlf = 0; hlf < (int)HLF_COUNT; hlf++) {
if (strncmp(hlf_names[hlf], p, nlen) == 0) {
if (strlen(hlf_names[hlf]) == nlen
&& strncmp(hlf_names[hlf], p, nlen) == 0) {
w_hl_ids[hlf] = hl_id;
break;
}

View File

@ -1186,6 +1186,7 @@ describe("'winhighlight' highlight", function()
[25] = {bold = true, foreground = Screen.colors.Green1},
[26] = {background = Screen.colors.Red},
[27] = {background = Screen.colors.DarkBlue, bold = true, foreground = Screen.colors.Green1},
[28] = {bold = true, foreground = Screen.colors.Brown},
})
command("hi Background1 guibg=DarkBlue")
command("hi Background2 guibg=DarkGreen")
@ -1598,4 +1599,45 @@ describe("'winhighlight' highlight", function()
{21:-- }{22:match 1 of 3} |
]])
end)
it('can override CursorLine and CursorLineNr', function()
-- CursorLine used to be parsed as CursorLineNr, because strncmp
command('set cursorline number')
command('split')
command('set winhl=CursorLine:Background1')
screen:expect{grid=[[
{28: 1 }{1:^ }|
{0:~ }|
{0:~ }|
{3:[No Name] }|
{28: 1 }{18: }|
{0:~ }|
{4:[No Name] }|
|
]]}
command('set winhl=CursorLineNr:Background2,CursorLine:Background1')
screen:expect{grid=[[
{5: 1 }{1:^ }|
{0:~ }|
{0:~ }|
{3:[No Name] }|
{28: 1 }{18: }|
{0:~ }|
{4:[No Name] }|
|
]]}
feed('<c-w>w')
screen:expect{grid=[[
{5: 1 }{1: }|
{0:~ }|
{0:~ }|
{4:[No Name] }|
{28: 1 }{18:^ }|
{0:~ }|
{3:[No Name] }|
|
]]}
end)
end)