mirror of
https://github.com/neovim/neovim
synced 2025-07-16 09:11:51 +00:00
fix(completion): check that healthcheck name is string (#28458)
This commit is contained in:
@ -2598,7 +2598,8 @@ static char *get_healthcheck_names(expand_T *xp FUNC_ATTR_UNUSED, int idx)
|
|||||||
last_gen = get_cmdline_last_prompt_id();
|
last_gen = get_cmdline_last_prompt_id();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (names.type == kObjectTypeArray && idx < (int)names.data.array.size) {
|
if (names.type == kObjectTypeArray && idx < (int)names.data.array.size
|
||||||
|
&& names.data.array.items[idx].type == kObjectTypeString) {
|
||||||
return names.data.array.items[idx].data.string.data;
|
return names.data.array.items[idx].data.string.data;
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -6,6 +6,8 @@ local curbuf_contents = t.curbuf_contents
|
|||||||
local command = t.command
|
local command = t.command
|
||||||
local eq, neq, matches = t.eq, t.neq, t.matches
|
local eq, neq, matches = t.eq, t.neq, t.matches
|
||||||
local getcompletion = t.fn.getcompletion
|
local getcompletion = t.fn.getcompletion
|
||||||
|
local exec_lua = t.exec_lua
|
||||||
|
local assert_alive = t.assert_alive
|
||||||
local insert = t.insert
|
local insert = t.insert
|
||||||
local source = t.source
|
local source = t.source
|
||||||
local fn = t.fn
|
local fn = t.fn
|
||||||
@ -20,6 +22,7 @@ describe(':checkhealth', function()
|
|||||||
eq(false, status)
|
eq(false, status)
|
||||||
eq('Invalid $VIMRUNTIME: bogus', string.match(err, 'Invalid.*'))
|
eq('Invalid $VIMRUNTIME: bogus', string.match(err, 'Invalid.*'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it("detects invalid 'runtimepath'", function()
|
it("detects invalid 'runtimepath'", function()
|
||||||
clear()
|
clear()
|
||||||
command('set runtimepath=bogus')
|
command('set runtimepath=bogus')
|
||||||
@ -27,6 +30,7 @@ describe(':checkhealth', function()
|
|||||||
eq(false, status)
|
eq(false, status)
|
||||||
eq("Invalid 'runtimepath'", string.match(err, 'Invalid.*'))
|
eq("Invalid 'runtimepath'", string.match(err, 'Invalid.*'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('detects invalid $VIM', function()
|
it('detects invalid $VIM', function()
|
||||||
clear()
|
clear()
|
||||||
-- Do this after startup, otherwise it just breaks $VIMRUNTIME.
|
-- Do this after startup, otherwise it just breaks $VIMRUNTIME.
|
||||||
@ -34,6 +38,7 @@ describe(':checkhealth', function()
|
|||||||
command('checkhealth nvim')
|
command('checkhealth nvim')
|
||||||
matches('ERROR $VIM .* zub', curbuf_contents())
|
matches('ERROR $VIM .* zub', curbuf_contents())
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('completions can be listed via getcompletion()', function()
|
it('completions can be listed via getcompletion()', function()
|
||||||
clear()
|
clear()
|
||||||
eq('nvim', getcompletion('nvim', 'checkhealth')[1])
|
eq('nvim', getcompletion('nvim', 'checkhealth')[1])
|
||||||
@ -41,6 +46,15 @@ describe(':checkhealth', function()
|
|||||||
eq('vim.lsp', getcompletion('vim.ls', 'checkhealth')[1])
|
eq('vim.lsp', getcompletion('vim.ls', 'checkhealth')[1])
|
||||||
neq('vim', getcompletion('^vim', 'checkhealth')[1]) -- should not complete vim.health
|
neq('vim', getcompletion('^vim', 'checkhealth')[1]) -- should not complete vim.health
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it('completion checks for vim.health._complete() return type #28456', function()
|
||||||
|
clear()
|
||||||
|
exec_lua([[vim.health._complete = function() return 1 end]])
|
||||||
|
eq({}, getcompletion('', 'checkhealth'))
|
||||||
|
exec_lua([[vim.health._complete = function() return { 1 } end]])
|
||||||
|
eq({}, getcompletion('', 'checkhealth'))
|
||||||
|
assert_alive()
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
describe('health.vim', function()
|
describe('health.vim', function()
|
||||||
|
Reference in New Issue
Block a user