diff options
| author | ii14 <59243201+ii14@users.noreply.github.com> | 2022-08-03 14:41:17 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-08-03 13:41:17 +0100 |
| commit | 3df8d9b8c56a7f0af0f7590b11831bd96ead92f1 (patch) | |
| tree | 23703fdf6aa7b32fe317e1cb5cbc6ee62e8d58c7 /src/nvim/eval | |
| parent | c57e133e50b9f3ccd9a3d73f4e7e3e7281797000 (diff) | |
| download | rneovim-3df8d9b8c56a7f0af0f7590b11831bd96ead92f1.tar.gz rneovim-3df8d9b8c56a7f0af0f7590b11831bd96ead92f1.tar.bz2 rneovim-3df8d9b8c56a7f0af0f7590b11831bd96ead92f1.zip | |
feat(lua): print source locations of lua callbacks (#19597)
Co-authored-by: ii14 <ii14@users.noreply.github.com>
Diffstat (limited to 'src/nvim/eval')
| -rw-r--r-- | src/nvim/eval/typval.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/nvim/eval/typval.c b/src/nvim/eval/typval.c index fd57b45e86..ff1808ed91 100644 --- a/src/nvim/eval/typval.c +++ b/src/nvim/eval/typval.c @@ -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; |