aboutsummaryrefslogtreecommitdiff
path: root/test/functional/api/highlight_spec.lua
diff options
context:
space:
mode:
authorkevinhwang91 <kevin.hwang@live.com>2020-01-08 22:19:23 +0800
committerJustin M. Keyes <justinkz@gmail.com>2020-01-08 06:19:23 -0800
commit831fa45ad84e2f41730db3350289e660006139d6 (patch)
treea5e2a633fd790580c097adf99a36f51a781c084c /test/functional/api/highlight_spec.lua
parenta91ea028303ea28a4667072d5db1ae10e8af80c9 (diff)
downloadrneovim-831fa45ad84e2f41730db3350289e660006139d6.tar.gz
rneovim-831fa45ad84e2f41730db3350289e660006139d6.tar.bz2
rneovim-831fa45ad84e2f41730db3350289e660006139d6.zip
API: nvim_get_hl_by_id: omit hl instead of returning -1 #11685
Problem: When Normal highlight group defines ctermfg/bg, but other highlight group lacks ctermfg/bg, nvim_get_hl_by_id(hl_id, v:false) returns -1 for the missing ctermfg/bg instead of just omitting it. Solution: checking for -1 in hlattrs2dict() fix #11680
Diffstat (limited to 'test/functional/api/highlight_spec.lua')
-rw-r--r--test/functional/api/highlight_spec.lua16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/functional/api/highlight_spec.lua b/test/functional/api/highlight_spec.lua
index b6514a105c..a9d4c72d31 100644
--- a/test/functional/api/highlight_spec.lua
+++ b/test/functional/api/highlight_spec.lua
@@ -70,6 +70,22 @@ describe('API: highlight',function()
eq(false, err)
eq('Invalid highlight id: -1',
string.match(emsg, 'Invalid.*'))
+
+ -- Test highlight group without ctermbg value.
+ command('hi Normal ctermfg=red ctermbg=yellow')
+ command('hi NewConstant ctermfg=green guifg=white guibg=blue')
+ hl_id = eval("hlID('NewConstant')")
+ eq({foreground = 10,}, meths.get_hl_by_id(hl_id, false))
+
+ -- Test highlight group without ctermfg value.
+ command('hi clear NewConstant')
+ command('hi NewConstant ctermbg=Magenta guifg=white guibg=blue')
+ eq({background = 13,}, meths.get_hl_by_id(hl_id, false))
+
+ -- Test highlight group with ctermfg and ctermbg values.
+ command('hi clear NewConstant')
+ command('hi NewConstant ctermfg=green ctermbg=Magenta guifg=white guibg=blue')
+ eq({foreground = 10, background = 13,}, meths.get_hl_by_id(hl_id, false))
end)
it("nvim_get_hl_by_name", function()