diff options
Diffstat (limited to 'src/nvim/api')
| -rw-r--r-- | src/nvim/api/private/helpers.c | 24 | ||||
| -rw-r--r-- | src/nvim/api/private/helpers.h | 8 |
2 files changed, 6 insertions, 26 deletions
diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c index a1af26e56f..cf82d907a3 100644 --- a/src/nvim/api/private/helpers.c +++ b/src/nvim/api/private/helpers.c @@ -1049,32 +1049,18 @@ const char *get_default_stl_hl(win_T *wp, bool use_winbar, int stc_hl_id) } } -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; - } -} - /// Sets sctx for API calls. /// -/// @param channel_id api clients id. Used to determine if it's a internal -/// call or a rpc call. -/// @return returns previous value of current_sctx. To be used -/// to be used for restoring sctx to previous state. +/// @param channel_id api client id to determine if it's a internal or RPC call. +/// +/// @return previous value of current_sctx. To be used later for restoring sctx. sctx_T api_set_sctx(uint64_t channel_id) { sctx_T old_current_sctx = current_sctx; if (channel_id != VIML_INTERNAL_CALL) { - current_sctx.sc_sid = - channel_id == LUA_INTERNAL_CALL ? SID_LUA : SID_API_CLIENT; + current_sctx.sc_sid = channel_id == LUA_INTERNAL_CALL ? SID_LUA : SID_API_CLIENT; current_sctx.sc_lnum = 0; + current_sctx.sc_chan = channel_id; } return old_current_sctx; } diff --git a/src/nvim/api/private/helpers.h b/src/nvim/api/private/helpers.h index 5cf1ca4d34..d51f99e5ac 100644 --- a/src/nvim/api/private/helpers.h +++ b/src/nvim/api/private/helpers.h @@ -186,13 +186,7 @@ typedef struct { #define WITH_SCRIPT_CONTEXT(channel_id, code) \ do { \ - const sctx_T save_current_sctx = current_sctx; \ - const uint64_t save_channel_id = current_channel_id; \ - 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 sctx_T save_current_sctx = api_set_sctx(channel_id); \ code; \ - current_channel_id = save_channel_id; \ current_sctx = save_current_sctx; \ } while (0); |