Merge pull request #23715 from neovim/backport-23702-to-release-0.9

[Backport release-0.9] fix(api): nvim_get_hl should return default flag
This commit is contained in:
zeertzjq
2023-05-22 16:59:33 +08:00
committed by GitHub
2 changed files with 8 additions and 0 deletions

View File

@@ -1537,6 +1537,9 @@ static bool hlgroup2dict(Dictionary *hl, NS ns_id, int hl_id, Arena *arena)
HlAttrs attr = HlAttrs attr =
syn_attr2entry(ns_id == 0 ? sgp->sg_attr : ns_get_hl(&ns_id, hl_id, false, sgp->sg_set)); syn_attr2entry(ns_id == 0 ? sgp->sg_attr : ns_get_hl(&ns_id, hl_id, false, sgp->sg_set));
*hl = arena_dict(arena, HLATTRS_DICT_SIZE + 1); *hl = arena_dict(arena, HLATTRS_DICT_SIZE + 1);
if (attr.rgb_ae_attr & HL_DEFAULT) {
PUT_C(*hl, "default", BOOLEAN_OBJ(true));
}
if (link > 0) { if (link > 0) {
PUT_C(*hl, "link", STRING_OBJ(cstr_as_string(hl_table[link - 1].sg_name))); PUT_C(*hl, "link", STRING_OBJ(cstr_as_string(hl_table[link - 1].sg_name)));
} }

View File

@@ -596,4 +596,9 @@ describe('API: get highlight', function()
eq({}, data["@foobar.hubbabubba"]) eq({}, data["@foobar.hubbabubba"])
eq(nil, data["@foobar"]) eq(nil, data["@foobar"])
end) end)
it('should return default flag', function()
meths.set_hl(0, 'Tried', { fg = "#00ff00", default = true })
eq({ fg = tonumber('00ff00', 16), default = true }, meths.get_hl(0, { name = 'Tried' }))
end)
end) end)