Browse Source

Merge pull request #11780 from bfredl/winhlparse

options: winhighlight: fix incorrect string equality test
tags/nightly
Björn Linse 8 months ago
committed by GitHub
parent
commit
01ff9db633
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 44 additions and 1 deletions
  1. +2
    -1
      src/nvim/option.c
  2. +42
    -0
      test/functional/ui/highlight_spec.lua

+ 2
- 1
src/nvim/option.c 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;
}


+ 42
- 0
test/functional/ui/highlight_spec.lua 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)

Loading…
Cancel
Save