From 7fb2310edb8f2fae1ddd175ef4bd6508ca3ce7e3 Mon Sep 17 00:00:00 2001 From: TJ DeVries Date: Wed, 30 Mar 2022 11:59:36 -0400 Subject: fix: set nested before executing callback (#17801) --- src/nvim/autocmd.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/nvim') diff --git a/src/nvim/autocmd.c b/src/nvim/autocmd.c index a36f2c97b5..d4af05b961 100644 --- a/src/nvim/autocmd.c +++ b/src/nvim/autocmd.c @@ -2022,6 +2022,11 @@ char_u *getnextac(int c, void *cookie, int indent, bool do_concat) verbose_leave_scroll(); } + // Make sure to set autocmd_nested before executing + // lua code, so that it works properly + autocmd_nested = ac->nested; + current_sctx = ac->script_ctx; + if (ac->exec.type == CALLABLE_CB) { typval_T argsin = TV_INITIAL_VALUE; typval_T rettv = TV_INITIAL_VALUE; @@ -2052,8 +2057,6 @@ char_u *getnextac(int c, void *cookie, int indent, bool do_concat) if (oneshot) { aucmd_del(ac); } - autocmd_nested = ac->nested; - current_sctx = ac->script_ctx; if (ac->last) { acp->nextcmd = NULL; } else { -- cgit