diff options
author | zeertzjq <zeertzjq@outlook.com> | 2025-02-25 09:17:51 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-02-25 01:17:51 +0000 |
commit | 095c0876c2010d6160df37cf057f2d0ad2c4501f (patch) | |
tree | a1ad1fbecda4626835bb415a3d4ee80f56c4362a /src/nvim/api/private/helpers.c | |
parent | 614c9322d50052c76fb3e6e1be7536a972ff0902 (diff) | |
download | rneovim-095c0876c2010d6160df37cf057f2d0ad2c4501f.tar.gz rneovim-095c0876c2010d6160df37cf057f2d0ad2c4501f.tar.bz2 rneovim-095c0876c2010d6160df37cf057f2d0ad2c4501f.zip |
fix(api): don't override Vimscript SID (#32610)
Problem: When calling an API from Vimscript to set an option, mapping,
etc., :verbose shows that it's set from an API client.
Solution: Don't override current_sctx.sc_sid when calling an API from
Vimscript. Also fix the inverse case where API channel id is
not set when calling an API from RPC. Move channel id into
sctx_T to make saving and restoring easier.
Related #8329
Diffstat (limited to 'src/nvim/api/private/helpers.c')
-rw-r--r-- | src/nvim/api/private/helpers.c | 24 |
1 files changed, 5 insertions, 19 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; } |