mirror of
https://github.com/neovim/neovim.git
synced 2025-11-08 03:25:05 +00:00
feat(vimscript): log function name in "fast" message #32616
This commit is contained in:
@@ -1179,7 +1179,10 @@ int nlua_call(lua_State *lstate)
|
|||||||
size_t name_len;
|
size_t name_len;
|
||||||
const char *name = luaL_checklstring(lstate, 1, &name_len);
|
const char *name = luaL_checklstring(lstate, 1, &name_len);
|
||||||
if (!nlua_is_deferred_safe() && !viml_func_is_fast(name)) {
|
if (!nlua_is_deferred_safe() && !viml_func_is_fast(name)) {
|
||||||
return luaL_error(lstate, e_fast_api_disabled, "Vimscript function");
|
size_t length = MIN(strlen(name), 100) + sizeof("Vimscript function \"\"");
|
||||||
|
vim_snprintf(IObuff, length, "Vimscript function \"%s\"", name);
|
||||||
|
int ret = luaL_error(lstate, e_fast_api_disabled, IObuff);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int nargs = lua_gettop(lstate) - 1;
|
int nargs = lua_gettop(lstate) - 1;
|
||||||
|
|||||||
@@ -1355,6 +1355,22 @@ describe('lua stdlib', function()
|
|||||||
)
|
)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it('vim.call fails in fast context', function()
|
||||||
|
local screen = Screen.new(120, 10)
|
||||||
|
exec_lua([[
|
||||||
|
local timer = vim.uv.new_timer()
|
||||||
|
timer:start(0, 0, function()
|
||||||
|
timer:close()
|
||||||
|
vim.call('sin', 0.0)
|
||||||
|
end)
|
||||||
|
]])
|
||||||
|
screen:expect({
|
||||||
|
any = pesc('E5560: Vimscript function "sin" must not be called in a fast event context'),
|
||||||
|
})
|
||||||
|
feed('<CR>')
|
||||||
|
assert_alive()
|
||||||
|
end)
|
||||||
|
|
||||||
it('vim.fn errors when calling API function', function()
|
it('vim.fn errors when calling API function', function()
|
||||||
matches(
|
matches(
|
||||||
'Tried to call API function with vim.fn: use vim.api.nvim_get_current_line instead',
|
'Tried to call API function with vim.fn: use vim.api.nvim_get_current_line instead',
|
||||||
|
|||||||
Reference in New Issue
Block a user