Mercurial > vim
diff src/userfunc.c @ 30126:01408b56f093 v9.0.0399
patch 9.0.0399: using :defer in expression funcref not tested
Commit: https://github.com/vim/vim/commit/98aff658d5f97629d7c3a9fccac6c79fc9c6029d
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Sep 6 21:02:35 2022 +0100
patch 9.0.0399: using :defer in expression funcref not tested
Problem: Using :defer in expression funcref not tested.
Solution: Add a test. Fix uncovered problems.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 06 Sep 2022 22:15:02 +0200 |
parents | 9874afdacb5f |
children | 6575d0bf6061 |
line wrap: on
line diff
--- a/src/userfunc.c +++ b/src/userfunc.c @@ -2593,6 +2593,7 @@ call_user_func( dict_T *selfdict) // Dictionary for "self" { sctx_T save_current_sctx; + ectx_T *save_current_ectx; int using_sandbox = FALSE; int save_sticky_cmdmod_flags = sticky_cmdmod_flags; funccall_T *fc; @@ -2669,9 +2670,9 @@ call_user_func( islambda = fp->uf_flags & FC_LAMBDA; /* - * Note about using fc->fc_fixvar[]: This is an array of FIXVAR_CNT variables - * with names up to VAR_SHORT_LEN long. This avoids having to alloc/free - * each argument variable and saves a lot of time. + * Note about using fc->fc_fixvar[]: This is an array of FIXVAR_CNT + * variables with names up to VAR_SHORT_LEN long. This avoids having to + * alloc/free each argument variable and saves a lot of time. */ /* * Init l: variables. @@ -2885,6 +2886,11 @@ call_user_func( // "legacy" does not apply to commands in the function sticky_cmdmod_flags = 0; + // If called from a compiled :def function the execution context must be + // hidden, any deferred functions need to be added to the function being + // executed here. + save_current_ectx = clear_currrent_ectx(); + save_current_sctx = current_sctx; current_sctx = fp->uf_script_ctx; save_did_emsg = did_emsg; @@ -2974,6 +2980,8 @@ call_user_func( ESTACK_CHECK_NOW estack_pop(); current_sctx = save_current_sctx; + restore_current_ectx(save_current_ectx); + #ifdef FEAT_PROFILE if (do_profiling == PROF_YES) script_prof_restore(&profile_info.pi_wait_start);