mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 03:18:16 +00:00
fix(options): fix 'winhl' still accepting invalid value (#30896)
This commit is contained in:
@@ -1853,6 +1853,9 @@ bool parse_winhl_opt(win_T *wp)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
int hl_id_link = nlen ? syn_check_group(p, nlen) : 0;
|
int hl_id_link = nlen ? syn_check_group(p, nlen) : 0;
|
||||||
|
if (hl_id_link == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
HlAttrs attrs = HLATTRS_INIT;
|
HlAttrs attrs = HLATTRS_INIT;
|
||||||
attrs.rgb_ae_attr |= HL_GLOBAL;
|
attrs.rgb_ae_attr |= HL_GLOBAL;
|
||||||
|
@@ -2426,16 +2426,24 @@ describe('highlight namespaces', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
it('winhl does not accept invalid value #24586', function()
|
it('winhl does not accept invalid value #24586', function()
|
||||||
local res = exec_lua([[
|
command('set winhl=Normal:Visual')
|
||||||
local curwin = vim.api.nvim_get_current_win()
|
for _, cmd in ipairs({
|
||||||
vim.api.nvim_command("set winhl=Normal:Visual")
|
[[set winhl='Normal:Wrong']],
|
||||||
local _, msg = pcall(vim.api.nvim_command,"set winhl='Normal:Wrong'")
|
[[set winhl=Normal:Wrong']],
|
||||||
return { msg, vim.wo[curwin].winhl }
|
[[set winhl='Normal:Wrong]],
|
||||||
]])
|
}) do
|
||||||
|
local res = exec_lua(
|
||||||
|
[[
|
||||||
|
local _, msg = pcall(vim.api.nvim_command, ...)
|
||||||
|
return { msg, vim.wo.winhl }
|
||||||
|
]],
|
||||||
|
cmd
|
||||||
|
)
|
||||||
eq({
|
eq({
|
||||||
'Vim(set):E5248: Invalid character in group name',
|
'Vim(set):E5248: Invalid character in group name',
|
||||||
'Normal:Visual',
|
'Normal:Visual',
|
||||||
}, res)
|
}, res)
|
||||||
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('Normal in set_hl #25474', function()
|
it('Normal in set_hl #25474', function()
|
||||||
|
@@ -84,14 +84,19 @@ let test_values = {
|
|||||||
"\ Nvim-only options
|
"\ Nvim-only options
|
||||||
\ 'channel': [[], []],
|
\ 'channel': [[], []],
|
||||||
\ 'inccommand': [['', 'nosplit', 'split'], ['xxx']],
|
\ 'inccommand': [['', 'nosplit', 'split'], ['xxx']],
|
||||||
\ 'mousescroll': [['ver:1', 'hor:2', 'ver:1,hor:2', 'hor:1,ver:2'], ['xxx']],
|
\ 'mousescroll': [['ver:1', 'hor:2', 'ver:1,hor:2', 'hor:1,ver:2'],
|
||||||
|
\ ['xxx', 'ver:1,xxx', 'hor:2,xxx']],
|
||||||
\ 'redrawdebug': [[''], ['xxx']],
|
\ 'redrawdebug': [[''], ['xxx']],
|
||||||
\ 'shada': [['', '''50', '"30'], ['xxx']],
|
\ 'shada': [['', '''50', '"30'], ['xxx']],
|
||||||
\ 'termpastefilter': [['BS', 'HT', 'FF', 'ESC', 'DEL', 'C0', 'C1', 'C0,C1'], ['xxx']],
|
\ 'termpastefilter': [['BS', 'HT', 'FF', 'ESC', 'DEL', 'C0', 'C1', 'C0,C1'],
|
||||||
\ 'winhighlight': [['', 'Visual:Search'], ['xxx']],
|
\ ['xxx', 'C0,C1,xxx']],
|
||||||
|
\ 'winhighlight': [['', 'a:b', 'a:', 'a:b,c:d'],
|
||||||
|
\ ['a', ':', ':b', 'a:b:c', 'a:/', '/:b', ',', 'a:b,,', 'a:b,c']],
|
||||||
\
|
\
|
||||||
"\ Options for which Nvim has different allowed values
|
"\ Options for which Nvim has different allowed values
|
||||||
\ 'backspace': [[2, '', 'eol', 'eol,start', 'indent,eol,nostop'], ['4', 'xxx']],
|
\ 'backspace': [[2, '', 'indent', 'eol', 'start', 'nostop',
|
||||||
|
\ 'eol,start', 'indent,eol,nostop'],
|
||||||
|
\ [-1, 4, 'xxx']],
|
||||||
\ 'buftype': [['', 'nofile', 'nowrite', 'acwrite', 'quickfix', 'help',
|
\ 'buftype': [['', 'nofile', 'nowrite', 'acwrite', 'quickfix', 'help',
|
||||||
\ 'prompt'],
|
\ 'prompt'],
|
||||||
\ ['xxx', 'help,nofile']],
|
\ ['xxx', 'help,nofile']],
|
||||||
@@ -105,7 +110,7 @@ let test_values = {
|
|||||||
\ 'highlight': [[&highlight], []],
|
\ 'highlight': [[&highlight], []],
|
||||||
\ 'iminsert': [[0, 1], [-1, 2, 3, 999]],
|
\ 'iminsert': [[0, 1], [-1, 2, 3, 999]],
|
||||||
\ 'imsearch': [[-1, 0, 1], [-2, 2, 3, 999]],
|
\ 'imsearch': [[-1, 0, 1], [-2, 2, 3, 999]],
|
||||||
\ 'signcolumn': [['auto', 'no'], ['xxx', 'no,yes']],
|
\ 'signcolumn': [['auto', 'no', 'yes', 'number'], ['', 'xxx', 'no,yes']],
|
||||||
\ 'writedelay': [[0, 100], [-1, '']],
|
\ 'writedelay': [[0, 100], [-1, '']],
|
||||||
\
|
\
|
||||||
"\ boolean options
|
"\ boolean options
|
||||||
|
Reference in New Issue
Block a user