mirror of
https://github.com/neovim/neovim.git
synced 2026-08-29 02:21:51 +00:00
fix(api): nvim_get_hl drops groups defined with link_global #38492
Problem: hlgroup2dict passes &ns_id to ns_get_hl twice. The first call
(link=true) sets *ns_hl = 0 when link_global is set, so the second call
and the sg_cleared guard both see ns_id == 0 and bail out. The group is
silently dropped from the result.
Solution: use a temporary copy of ns_id for each ns_get_hl call so the
original value is preserved.
(cherry picked from commit 49086862fc)
This commit is contained in:
committed by
github-actions[bot]
parent
452a9b895c
commit
4053141cb3
@@ -610,6 +610,22 @@ describe('API: get highlight', function()
|
||||
eq(hl, api.nvim_get_hl(0, { name = 'Foo', link = true }))
|
||||
end)
|
||||
|
||||
it('link_global resolves in global namespace', function()
|
||||
local ns = api.nvim_create_namespace('hl_test')
|
||||
api.nvim_set_hl(0, 'GlTarget', { fg = '#ff0000' })
|
||||
api.nvim_set_hl(ns, 'GlSource', { link_global = fn.hlID('GlTarget') })
|
||||
eq({ link = 'GlTarget' }, api.nvim_get_hl(ns, { name = 'GlSource' }))
|
||||
|
||||
-- when both link and link_global are given, link_global wins
|
||||
api.nvim_set_hl(0, 'OtherTarget', { fg = '#00ff00' })
|
||||
api.nvim_set_hl(
|
||||
ns,
|
||||
'GlSource',
|
||||
{ link = fn.hlID('OtherTarget'), link_global = fn.hlID('GlTarget') }
|
||||
)
|
||||
eq({ link = 'GlTarget' }, api.nvim_get_hl(ns, { name = 'GlSource' }))
|
||||
end)
|
||||
|
||||
it("doesn't contain unset groups", function()
|
||||
local id = api.nvim_get_hl_id_by_name '@foobar.hubbabubba'
|
||||
ok(id > 0)
|
||||
|
||||
Reference in New Issue
Block a user