feat(lua): print source locations of lua callbacks (#19597)

Co-authored-by: ii14 <ii14@users.noreply.github.com>
This commit is contained in:
ii14
2022-08-03 14:41:17 +02:00
committed by GitHub
parent c57e133e50
commit 3df8d9b8c5
8 changed files with 66 additions and 21 deletions

View File

@@ -1657,13 +1657,14 @@ void callback_copy(Callback *dest, Callback *src)
/// Generate a string description of a callback
char *callback_to_string(Callback *cb)
{
size_t msglen = 100;
if (cb->type == kCallbackLua) {
return nlua_funcref_str(cb->data.luaref);
}
const size_t msglen = 100;
char *msg = (char *)xmallocz(msglen);
switch (cb->type) {
case kCallbackLua:
snprintf(msg, msglen, "<lua: %d>", cb->data.luaref);
break;
case kCallbackFuncref:
// TODO(tjdevries): Is this enough space for this?
snprintf(msg, msglen, "<vim function: %s>", cb->data.funcref);
@@ -1672,7 +1673,7 @@ char *callback_to_string(Callback *cb)
snprintf(msg, msglen, "<vim partial: %s>", cb->data.partial->pt_name);
break;
default:
snprintf(msg, msglen, "%s", "");
*msg = '\0';
break;
}
return msg;