diff options
-rw-r--r-- | src/nvim/api/vim.c | 10 | ||||
-rw-r--r-- | src/nvim/syntax.c | 4 | ||||
-rw-r--r-- | test/functional/api/highlight_spec.lua | 20 |
3 files changed, 17 insertions, 17 deletions
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index bf3e4bc6a0..0c3c497533 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -59,9 +59,10 @@ void nvim_command(String command, Error *err) /// Retrieves highlight description from its name /// /// @param name Highlight group name +/// @param rgb True to export GUI values /// @return a highlight description e.g. {'bold': true, 'bg': 123, 'fg': 42} /// @see nvim_get_hl_by_id -Dictionary nvim_get_hl_by_name(String name, Error *err) +Dictionary nvim_get_hl_by_name(String name, Boolean rgb, Error *err) FUNC_API_SINCE(3) { Dictionary result = ARRAY_DICT_INIT; @@ -72,15 +73,16 @@ Dictionary nvim_get_hl_by_name(String name, Error *err) name.data); return result; } - result = nvim_get_hl_by_id(id, err); + result = nvim_get_hl_by_id(id, rgb, err); return result; } /// Retrieves highlight description from its id /// /// @param hl_id highlight id as returned by |hlID()| +/// @param rgb True to export GUI values /// @see nvim_get_hl_by_name -Dictionary nvim_get_hl_by_id(Integer hl_id, Error *err) +Dictionary nvim_get_hl_by_id(Integer hl_id, Boolean rgb, Error *err) FUNC_API_SINCE(3) { Dictionary dic = ARRAY_DICT_INIT; @@ -89,7 +91,7 @@ Dictionary nvim_get_hl_by_id(Integer hl_id, Error *err) return dic; } int attrcode = syn_id2attr((int)hl_id); - return hl_get_attr_by_id(attrcode, err); + return hl_get_attr_by_id(attrcode, rgb, err); } /// Passes input keys to Nvim. diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c index 2f48cc8757..32567a63de 100644 --- a/src/nvim/syntax.c +++ b/src/nvim/syntax.c @@ -8224,7 +8224,7 @@ RgbValue name_to_color(const uint8_t *name) /// Retrieves attribute description from its id /// /// @param attr_id attribute id -Dictionary hl_get_attr_by_id(Integer attr_id, Error *err) +Dictionary hl_get_attr_by_id(Integer attr_id, Boolean rgb, Error *err) { HlAttrs attrs = HLATTRS_INIT; Dictionary dic = ARRAY_DICT_INIT; @@ -8240,7 +8240,7 @@ Dictionary hl_get_attr_by_id(Integer attr_id, Error *err) return dic; } - attrs = attrentry2hlattrs(aep, p_tgc); + attrs = attrentry2hlattrs(aep, rgb); end: return hlattrs2dict(attrs); diff --git a/test/functional/api/highlight_spec.lua b/test/functional/api/highlight_spec.lua index a5d3871d13..4082b0daf9 100644 --- a/test/functional/api/highlight_spec.lua +++ b/test/functional/api/highlight_spec.lua @@ -27,14 +27,13 @@ describe('highlight api',function() it("nvim_get_hl_by_id", function() local hl_id = eval("hlID('NewHighlight')") - eq(expected_cterm, nvim("get_hl_by_id", hl_id)) + eq(expected_cterm, nvim("get_hl_by_id", hl_id, false)) - command('set termguicolors') hl_id = eval("hlID('NewHighlight')") - eq(expected_rgb, nvim("get_hl_by_id", hl_id)) + eq(expected_rgb, nvim("get_hl_by_id", hl_id, true)) - -- assume there is no hl with id 30000 - local err, emsg = pcall(meths.get_hl_by_id, 30000) + -- assume there is no hl with id = 30000 + local err, emsg = pcall(meths.get_hl_by_id, 30000, false) eq(false, err) ok(string.find(emsg, 'Invalid highlight id') ~= nil) end) @@ -44,16 +43,15 @@ describe('highlight api',function() foreground = Screen.colors.Red } -- test "Normal" hl defaults - eq({}, nvim("get_hl_by_name", 'Normal')) + eq({}, nvim("get_hl_by_name", 'Normal', true)) - eq(expected_cterm, nvim("get_hl_by_name", 'NewHighlight')) - command('set termguicolors') - eq(expected_rgb, nvim("get_hl_by_name", 'NewHighlight')) + eq(expected_cterm, nvim("get_hl_by_name", 'NewHighlight', false)) + eq(expected_rgb, nvim("get_hl_by_name", 'NewHighlight', true)) command('hi Normal guifg=red guibg=yellow') - eq(expected_normal, nvim("get_hl_by_name", 'Normal')) + eq(expected_normal, nvim("get_hl_by_name", 'Normal', true)) - local err, emsg = pcall(meths.get_hl_by_name , 'unknown_highlight') + local err, emsg = pcall(meths.get_hl_by_name , 'unknown_highlight', false) eq(false, err) ok(string.find(emsg, 'Invalid highlight name') ~= nil) end) |