diff options
author | Marco Hinz <mh.codebro@gmail.com> | 2015-07-18 16:57:53 +0200 |
---|---|---|
committer | Marco Hinz <mh.codebro@gmail.com> | 2015-07-18 16:58:09 +0200 |
commit | 54195c829d9b39ab241b9d6a34d3d876ad3f2554 (patch) | |
tree | 548dc9ed5f9afc2048f4911d902ea5fcd1442152 | |
parent | 7732bec9b8b94cb43647dcb7f5bd2619224bd87a (diff) | |
parent | 9d876eb0374cf87455d56ffd62c1c8e90c423876 (diff) | |
download | rneovim-54195c829d9b39ab241b9d6a34d3d876ad3f2554.tar.gz rneovim-54195c829d9b39ab241b9d6a34d3d876ad3f2554.tar.bz2 rneovim-54195c829d9b39ab241b9d6a34d3d876ad3f2554.zip |
Merge #3005 'synIDattr(): true color awareness'
-rw-r--r-- | src/nvim/eval.c | 2 | ||||
-rw-r--r-- | test/functional/terminal/highlight_spec.lua | 25 |
2 files changed, 27 insertions, 0 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 21f21a4c80..9957643c8d 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -14699,6 +14699,8 @@ static void f_synIDattr(typval_T *argvars, typval_T *rettv) modec = TOLOWER_ASC(mode[0]); if (modec != 'c' && modec != 'g') modec = 0; /* replace invalid with current */ + } else if (ui_rgb_attached()) { + modec = 'g'; } else { modec = 'c'; } diff --git a/test/functional/terminal/highlight_spec.lua b/test/functional/terminal/highlight_spec.lua index b72527e7b6..1a96cb4dba 100644 --- a/test/functional/terminal/highlight_spec.lua +++ b/test/functional/terminal/highlight_spec.lua @@ -3,6 +3,7 @@ local Screen = require('test.functional.ui.screen') local thelpers = require('test.functional.terminal.helpers') local feed, clear, nvim = helpers.feed, helpers.clear, helpers.nvim local nvim_dir, execute = helpers.nvim_dir, helpers.execute +local eq, eval = helpers.eq, helpers.eval describe('terminal window highlighting', function() @@ -161,3 +162,27 @@ describe('terminal window highlighting with custom palette', function() ]]) end) end) + +describe('synIDattr()', function() + local screen + + before_each(function() + clear() + screen = Screen.new(50, 7) + execute('highlight Normal ctermfg=1 guifg=#ff0000') + end) + + after_each(function() + screen:detach() + end) + + it('returns RGB number if GUI', function() + screen:attach(true) + eq('#ff0000', eval('synIDattr(hlID("Normal"), "fg")')) + end) + + it('returns color number if non-GUI', function() + screen:attach(false) + eq('1', eval('synIDattr(hlID("Normal"), "fg")')) + end) +end) |