diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-09-24 10:57:09 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-24 10:57:09 +0800 |
commit | 4d3a38ac074fff7e2a4bede4cee7699bdd55ffdc (patch) | |
tree | aba2143d3a3356e5721b511798a0f4f0d466bf03 /src/nvim/lua/stdlib.c | |
parent | 046c9a83f7ed2694c19d915a63ef0dfed9d29dc5 (diff) | |
download | rneovim-4d3a38ac074fff7e2a4bede4cee7699bdd55ffdc.tar.gz rneovim-4d3a38ac074fff7e2a4bede4cee7699bdd55ffdc.tar.bz2 rneovim-4d3a38ac074fff7e2a4bede4cee7699bdd55ffdc.zip |
fix(api, lua): handle setting v: variables properly (#25325)
Diffstat (limited to 'src/nvim/lua/stdlib.c')
-rw-r--r-- | src/nvim/lua/stdlib.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/nvim/lua/stdlib.c b/src/nvim/lua/stdlib.c index 8f1b5c7b86..f175a7abb0 100644 --- a/src/nvim/lua/stdlib.c +++ b/src/nvim/lua/stdlib.c @@ -24,6 +24,7 @@ #include "nvim/buffer_defs.h" #include "nvim/eval/typval.h" #include "nvim/eval/typval_defs.h" +#include "nvim/eval/vars.h" #include "nvim/ex_eval.h" #include "nvim/fold.h" #include "nvim/globals.h" @@ -397,6 +398,15 @@ int nlua_setvar(lua_State *lstate) di = tv_dict_item_alloc_len(key.data, key.size); tv_dict_add(dict, di); } else { + bool type_error = false; + if (dict == &vimvardict + && !before_set_vvar(key.data, di, &tv, true, watched, &type_error)) { + tv_clear(&tv); + if (type_error) { + return luaL_error(lstate, "Setting v:%s to value with wrong type", key.data); + } + return 0; + } if (watched) { tv_copy(&di->di_tv, &oldtv); } |