mirror of
https://github.com/neovim/neovim.git
synced 2026-08-30 02:51:48 +00:00
fix(api): expose fg_indexed/bg_indexed in nvim_get_hl #39210
Problem: fg_indexed/bg_indexed were dropped from nvim_get_hl output due to a wrong short_keys guard. HL_FG_INDEXED also wasn't cleared in hl_blend_attrs, and HLATTRS_DICT_SIZE was too small. Solution: Remove the short_keys guard, clear HL_FG_INDEXED in hl_blend_attrs, bump HLATTRS_DICT_SIZE to 24, and clarify docs that these flags mean rgb is an approximation of the cterm palette index.
This commit is contained in:
@@ -715,6 +715,29 @@ describe('API: get highlight', function()
|
||||
api.nvim_set_hl(0, 'Bar', { link = 'Foo', default = true, force = true })
|
||||
eq({ link = 'Foo', default = true }, api.nvim_get_hl(0, { name = 'Bar' }))
|
||||
end)
|
||||
|
||||
it('round-trips fg_indexed/bg_indexed through nvim_get_hl', function()
|
||||
api.nvim_set_hl(0, 'Test_idx', {
|
||||
fg = '#cc0000',
|
||||
bg = '#0000cc',
|
||||
ctermfg = 1,
|
||||
ctermbg = 4,
|
||||
fg_indexed = true,
|
||||
bg_indexed = true,
|
||||
})
|
||||
local hl = api.nvim_get_hl(0, { name = 'Test_idx' })
|
||||
eq(true, hl.fg_indexed)
|
||||
eq(true, hl.bg_indexed)
|
||||
eq(tonumber('0xcc0000'), hl.fg)
|
||||
eq(tonumber('0x0000cc'), hl.bg)
|
||||
eq(1, hl.ctermfg)
|
||||
eq(4, hl.ctermbg)
|
||||
|
||||
api.nvim_set_hl(0, 'Test_idx', { fg_indexed = false, update = true })
|
||||
eq(nil, api.nvim_get_hl(0, { name = 'Test_idx' }).fg_indexed)
|
||||
eq(true, api.nvim_get_hl(0, { name = 'Test_idx' }).bg_indexed)
|
||||
eq(tonumber('0xcc0000'), api.nvim_get_hl(0, { name = 'Test_idx' }).fg)
|
||||
end)
|
||||
end)
|
||||
|
||||
describe('API: set/get highlight namespace', function()
|
||||
|
||||
Reference in New Issue
Block a user