fix(highlight): add force in nvim_set_hl

This commit is contained in:
glepnir
2023-09-18 14:50:27 +08:00
parent 71530cc972
commit f8ea49cfe1
7 changed files with 19 additions and 2 deletions

View File

@@ -625,4 +625,15 @@ describe('API: get highlight', function()
eq('FooBarA xxx cterm=bold,italic guifg=#ffffff',
exec_capture('highlight FooBarA'))
end)
it('can override exist highlight group by force #20323', function()
local white = tonumber('ffffff', 16)
local green = tonumber('00ff00', 16)
meths.set_hl(0, 'Foo', { fg=white })
meths.set_hl(0, 'Foo', { fg=green, force = true })
eq({ fg = green },meths.get_hl(0, {name = 'Foo'}))
meths.set_hl(0, 'Bar', {link = 'Comment', default = true})
meths.set_hl(0, 'Bar', {link = 'Foo',default = true, force = true})
eq({link ='Foo', default = true}, meths.get_hl(0, {name = 'Bar'}))
end)
end)