diff options
author | bfredl <bjorn.linse@gmail.com> | 2022-02-28 00:07:31 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-28 00:07:31 +0100 |
commit | fad33b095fcc2607ea9f058b5fa76cda9483a24e (patch) | |
tree | 8d453a80320e49c2748f03240db8a4338384c9a1 /src/nvim/api/private/helpers.c | |
parent | 1b5767aa3480c0cdc43f7a4b78f36a14e85a182f (diff) | |
parent | 991e472881bf29805982b402c1a010cde051ded3 (diff) | |
download | rneovim-fad33b095fcc2607ea9f058b5fa76cda9483a24e.tar.gz rneovim-fad33b095fcc2607ea9f058b5fa76cda9483a24e.tar.bz2 rneovim-fad33b095fcc2607ea9f058b5fa76cda9483a24e.zip |
Merge pull request #14661 from tjdevries/tjdevries/lua_autocmd_v2
lua: autocmds take 2: electric autoroo
Diffstat (limited to 'src/nvim/api/private/helpers.c')
-rw-r--r-- | src/nvim/api/private/helpers.c | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c index 971fa1cb0f..3d4a04f096 100644 --- a/src/nvim/api/private/helpers.c +++ b/src/nvim/api/private/helpers.c @@ -396,19 +396,14 @@ void set_option_to(uint64_t channel_id, void *to, int type, String name, Object stringval = value.data.string.data; } - const sctx_T save_current_sctx = current_sctx; - current_sctx.sc_sid = - channel_id == LUA_INTERNAL_CALL ? SID_LUA : SID_API_CLIENT; - current_sctx.sc_lnum = 0; - current_channel_id = channel_id; - - const int opt_flags = (type == SREQ_WIN && !(flags & SOPT_GLOBAL)) - ? 0 : (type == SREQ_GLOBAL) - ? OPT_GLOBAL : OPT_LOCAL; - set_option_value_for(name.data, numval, stringval, - opt_flags, type, to, err); - - current_sctx = save_current_sctx; + WITH_SCRIPT_CONTEXT(channel_id, { + const int opt_flags = (type == SREQ_WIN && !(flags & SOPT_GLOBAL)) + ? 0 : (type == SREQ_GLOBAL) + ? OPT_GLOBAL : OPT_LOCAL; + + set_option_value_for(name.data, numval, stringval, + opt_flags, type, to, err); + }); } buf_T *find_buffer_by_handle(Buffer buffer, Error *err) @@ -1614,3 +1609,16 @@ err: NLUA_CLEAR_REF(luaref); NLUA_CLEAR_REF(compl_luaref); } + +int find_sid(uint64_t channel_id) +{ + switch (channel_id) { + case VIML_INTERNAL_CALL: + // TODO(autocmd): Figure out what this should be + // return SID_API_CLIENT; + case LUA_INTERNAL_CALL: + return SID_LUA; + default: + return SID_API_CLIENT; + } +} |