neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit c6cc56d69cf294e8b91602a2f34a261325691286
parent b2265bb72c268c95180dc92c129be11fd87f995d
Author: bfredl <bjorn.linse@gmail.com>
Date:   Wed, 20 Sep 2023 09:18:59 +0200

Merge pull request #25155 from glepnir/fix_winhl

fix(highlight): winhl receive wrong argument
Diffstat:
Msrc/nvim/option.c | 3+++
Mtest/functional/ui/highlight_spec.lua | 14++++++++++++++
2 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/src/nvim/option.c b/src/nvim/option.c @@ -1915,6 +1915,9 @@ bool parse_winhl_opt(win_T *wp) char *commap = xstrchrnul(hi, ','); size_t len = (size_t)(commap - hi); int hl_id = len ? syn_check_group(hi, len) : -1; + if (hl_id == 0) { + return false; + } int hl_id_link = nlen ? syn_check_group(p, nlen) : 0; HlAttrs attrs = HLATTRS_INIT; diff --git a/test/functional/ui/highlight_spec.lua b/test/functional/ui/highlight_spec.lua @@ -8,6 +8,7 @@ local feed_command, eq = helpers.feed_command, helpers.eq local curbufmeths = helpers.curbufmeths local funcs = helpers.funcs local meths = helpers.meths +local exec_lua = helpers.exec_lua describe('colorscheme compatibility', function() before_each(function() @@ -2641,4 +2642,17 @@ describe('highlight namespaces', function() | ]]} end) + + it('winhl does not accept invalid value #24586', function() + local res = exec_lua([[ + local curwin = vim.api.nvim_get_current_win() + vim.api.nvim_command("set winhl=Normal:Visual") + local _, msg = pcall(vim.api.nvim_command,"set winhl='Normal:Wrong'") + return { msg, vim.wo[curwin].winhl } + ]]) + eq({ + "Vim(set):E5248: Invalid character in group name", + "Normal:Visual", + },res) + end) end)