aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/mapping.c
diff options
context:
space:
mode:
authorbfredl <bjorn.linse@gmail.com>2024-02-12 20:40:27 +0100
committerbfredl <bjorn.linse@gmail.com>2024-02-15 10:42:06 +0100
commitd60412b18e4e21f301baa2ac3f3fb7be89655e4b (patch)
tree2459531b83b937b6678ee7141badc27d0a331c29 /src/nvim/mapping.c
parent0a51e7626a95a068c7bb00d0da28a701fed758da (diff)
downloadrneovim-d60412b18e4e21f301baa2ac3f3fb7be89655e4b.tar.gz
rneovim-d60412b18e4e21f301baa2ac3f3fb7be89655e4b.tar.bz2
rneovim-d60412b18e4e21f301baa2ac3f3fb7be89655e4b.zip
refactor(eval): use arena when converting typvals to Object
Note: this contains two _temporary_ changes which can be reverted once the Arena vs no-Arena distinction in API wrappers has been removed. Both nlua_push_Object and object_to_vim_take_luaref() has been changed to take the object argument as a pointer. This is not going to be necessary once these are only used with arena (or not at all) allocated Objects. The object_to_vim() variant which leaves luaref untouched might need to stay for a little longer.
Diffstat (limited to 'src/nvim/mapping.c')
-rw-r--r--src/nvim/mapping.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/nvim/mapping.c b/src/nvim/mapping.c
index 59022e8be6..963f65148d 100644
--- a/src/nvim/mapping.c
+++ b/src/nvim/mapping.c
@@ -22,6 +22,7 @@
#include "nvim/eval.h"
#include "nvim/eval/typval.h"
#include "nvim/eval/typval_defs.h"
+#include "nvim/eval/userfunc.h"
#include "nvim/ex_cmds_defs.h"
#include "nvim/ex_session.h"
#include "nvim/garray.h"
@@ -2305,13 +2306,13 @@ void f_mapset(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
LuaRef rhs_lua = LUA_NOREF;
dictitem_T *callback_di = tv_dict_find(d, S_LEN("callback"));
if (callback_di != NULL) {
- Object callback_obj = vim_to_object(&callback_di->di_tv);
- if (callback_obj.type == kObjectTypeLuaRef && callback_obj.data.luaref != LUA_NOREF) {
- rhs_lua = callback_obj.data.luaref;
- orig_rhs = "";
- callback_obj.data.luaref = LUA_NOREF;
+ if (callback_di->di_tv.v_type == VAR_FUNC) {
+ ufunc_T *fp = find_func(callback_di->di_tv.vval.v_string);
+ if (fp != NULL && (fp->uf_flags & FC_LUAREF)) {
+ rhs_lua = api_new_luaref(fp->uf_luaref);
+ orig_rhs = "";
+ }
}
- api_free_object(callback_obj);
}
if (lhs == NULL || lhsraw == NULL || orig_rhs == NULL) {
emsg(_(e_entries_missing_in_mapset_dict_argument));