fix(lua): show stacktrace for error in vim.on_key() callback (#31021)

This commit is contained in:
zeertzjq
2024-11-02 10:11:06 +08:00
committed by GitHub
parent b25ae5d328
commit 3688a33354
3 changed files with 39 additions and 19 deletions

View File

@@ -2099,9 +2099,9 @@ bool nlua_execute_on_key(int c, char *typed_buf)
int save_got_int = got_int;
got_int = false; // avoid interrupts when the key typed is Ctrl-C
bool discard = false;
if (nlua_pcall(lstate, 2, 1)) {
nlua_error(lstate,
_("Error executing vim.on_key Lua callback: %.*s"));
// Do not use nlua_pcall here to avoid duplicate stack trace information
if (lua_pcall(lstate, 2, 1, 0)) {
nlua_error(lstate, _("Error executing vim.on_key() callbacks: %.*s"));
} else {
if (lua_isboolean(lstate, -1)) {
discard = lua_toboolean(lstate, -1);