aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/api/private/helpers.h
diff options
context:
space:
mode:
authorglacambre <code@lacamb.re>2023-02-11 13:51:33 +0100
committerglacambre <code@lacamb.re>2023-02-11 14:02:17 +0100
commit5ca6cf55f9c772f5c691b08dc49581f27f88e8f9 (patch)
tree15f7b4bc8466d7427b35276c10cd080bd52e7f49 /src/nvim/api/private/helpers.h
parentc9b0fe1f41ebaa6815a69ac614a5b2d1bab6f720 (diff)
downloadrneovim-5ca6cf55f9c772f5c691b08dc49581f27f88e8f9.tar.gz
rneovim-5ca6cf55f9c772f5c691b08dc49581f27f88e8f9.tar.bz2
rneovim-5ca6cf55f9c772f5c691b08dc49581f27f88e8f9.zip
fix(helpers): restore channel id after a call to WITH_SCRIPT_CONTEXT
In https://github.com/neovim/neovim/pull/22214, init_default_autocmds has been turned into a lua function call to nvim_create_augroup and nvim_create_autocmd. This introduced a strange regression: a test in vim_spec.lua started failing with its last_set_chan value switching from 0 to -9223372036854775808. It turns out that -9223372036854775808 is the value of LUA_INTERNAL_CALL and would be inherited as last_set_chan by options set from the command line due to the WITH_SCRIPT_CONTEXT macro not restoring the channel id (WITH_SCRIPT_CONTEXT is used by nvim_create_augroup).
Diffstat (limited to 'src/nvim/api/private/helpers.h')
-rw-r--r--src/nvim/api/private/helpers.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/nvim/api/private/helpers.h b/src/nvim/api/private/helpers.h
index ec97ba9ec6..b70452d7cb 100644
--- a/src/nvim/api/private/helpers.h
+++ b/src/nvim/api/private/helpers.h
@@ -175,11 +175,13 @@ 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; \
code; \
+ current_channel_id = save_channel_id; \
current_sctx = save_current_sctx; \
} while (0);