diff options
author | bfredl <bjorn.linse@gmail.com> | 2022-08-17 17:38:35 +0200 |
---|---|---|
committer | bfredl <bjorn.linse@gmail.com> | 2022-08-18 10:57:46 +0200 |
commit | e29156356b1895473d2f55c729d949c73014cd3c (patch) | |
tree | 26c5635d075a5cccce1fdf4e19f2a3b67ad4a30f | |
parent | 02e9b5a8eeaf2a4696dd68ab21b33b9fa7bd6a16 (diff) | |
download | rneovim-e29156356b1895473d2f55c729d949c73014cd3c.tar.gz rneovim-e29156356b1895473d2f55c729d949c73014cd3c.tar.bz2 rneovim-e29156356b1895473d2f55c729d949c73014cd3c.zip |
fix(api): make nvim_set_hl(ns=0, ...) redraw screen properly
fixes #18160
-rw-r--r-- | src/nvim/highlight.c | 2 | ||||
-rw-r--r-- | src/nvim/highlight_group.c | 10 | ||||
-rw-r--r-- | test/functional/ui/highlight_spec.lua | 30 |
3 files changed, 39 insertions, 3 deletions
diff --git a/src/nvim/highlight.c b/src/nvim/highlight.c index 504cae9a51..21d7f9ada1 100644 --- a/src/nvim/highlight.c +++ b/src/nvim/highlight.c @@ -303,8 +303,6 @@ int hl_get_ui_attr(int ns_id, int idx, int final_id, bool optional) if (pum_drawn()) { must_redraw_pum = true; } - } else if (idx == HLF_MSG && ns_id == -1) { - msg_grid.blending = attrs.hl_blend > -1; } if (optional && !available) { diff --git a/src/nvim/highlight_group.c b/src/nvim/highlight_group.c index 616c2a670d..85c60a8cf8 100644 --- a/src/nvim/highlight_group.c +++ b/src/nvim/highlight_group.c @@ -698,7 +698,7 @@ void set_hl_group(int id, HlAttrs attrs, Dict(highlight) *dict, int link_id) g->sg_deflink_sctx = current_sctx; g->sg_deflink_sctx.sc_lnum += SOURCING_LNUM; } - return; + goto update; } g->sg_cleared = false; @@ -753,6 +753,12 @@ void set_hl_group(int id, HlAttrs attrs, Dict(highlight) *dict, int link_id) ui_mode_info_set(); } } + +update: + if (!updating_screen) { + redraw_all_later(NOT_VALID); + } + need_highlight_changed = true; } /// Handle ":highlight" command @@ -1942,6 +1948,8 @@ void highlight_changed(void) if (highlight_attr[hlf] != highlight_attr_last[hlf]) { if (hlf == HLF_MSG) { clear_cmdline = true; + HlAttrs attrs = syn_attr2entry(highlight_attr[hlf]); + msg_grid.blending = attrs.hl_blend > -1; } ui_call_hl_group_set(cstr_as_string((char *)hlf_names[hlf]), highlight_attr[hlf]); diff --git a/test/functional/ui/highlight_spec.lua b/test/functional/ui/highlight_spec.lua index a3943d40b6..28f4c0eb23 100644 --- a/test/functional/ui/highlight_spec.lua +++ b/test/functional/ui/highlight_spec.lua @@ -2335,6 +2335,7 @@ describe('highlight namespaces', function() [5] = {background = Screen.colors.Magenta4, foreground = Screen.colors.Crimson}; [6] = {bold = true, reverse = true}; [7] = {reverse = true}; + [8] = {foreground = Screen.colors.Gray20}; } ns1 = meths.create_namespace 'grungy' @@ -2425,4 +2426,33 @@ describe('highlight namespaces', function() | ]]} end) + + it('redraws correctly when ns=0', function() + screen:expect{grid=[[ + ^ | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + + meths.set_hl(0, 'EndOfBuffer', {fg='#333333'}) + screen:expect{grid=[[ + ^ | + {8:~ }| + {8:~ }| + {8:~ }| + {8:~ }| + {8:~ }| + {8:~ }| + {8:~ }| + {8:~ }| + | + ]]} + end) end) |