Mercurial > vim
changeset 27678:1646525507aa v8.2.4365
patch 8.2.4365: sticky command modifiers are too sticky
Commit: https://github.com/vim/vim/commit/cdf04859699bdde891b5b52ea821d0bebd7e8ee0
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Feb 12 22:13:06 2022 +0000
patch 8.2.4365: sticky command modifiers are too sticky
Problem: sticky command modifiers are too sticky.
Solution: Do not apply command modifiers to a called function. (closes https://github.com/vim/vim/issues/9751)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 12 Feb 2022 23:15:03 +0100 |
parents | 567f4f964ccc |
children | 3d939fced94d |
files | src/testdir/test_vim9_cmd.vim src/userfunc.c src/version.c |
diffstat | 3 files changed, 23 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/testdir/test_vim9_cmd.vim +++ b/src/testdir/test_vim9_cmd.vim @@ -118,6 +118,20 @@ def Test_cmdmod_execute() END v9.CheckScriptSuccess(lines) delete('Xvim9import.vim') + + # "legacy" does not aply to a called function + lines =<< trim END + vim9script + + def g:TheFunc() + if exists('something') + echo 'yes' + endif + enddef + legacy exe 'call g:TheFunc()' + END + v9.CheckScriptSuccess(lines) + delfunc g:TheFunc enddef def Test_edit_wildcards()
--- a/src/userfunc.c +++ b/src/userfunc.c @@ -2513,6 +2513,7 @@ call_user_func( { sctx_T save_current_sctx; int using_sandbox = FALSE; + int save_sticky_cmdmod_flags = sticky_cmdmod_flags; funccall_T *fc; int save_did_emsg; int default_arg_err = FALSE; @@ -2569,6 +2570,7 @@ call_user_func( if (do_profiling == PROF_YES) profile_may_start_func(&profile_info, fp, caller); #endif + sticky_cmdmod_flags = 0; call_def_function(fp, argcount, argvars, funcexe->fe_partial, rettv); funcdepth_decrement(); #ifdef FEAT_PROFILE @@ -2578,6 +2580,7 @@ call_user_func( #endif current_funccal = fc->caller; free_funccal(fc); + sticky_cmdmod_flags = save_sticky_cmdmod_flags; return; } @@ -2797,6 +2800,9 @@ call_user_func( fc->caller == NULL ? NULL : fc->caller->func); #endif + // "legacy" does not apply to commands in the function + sticky_cmdmod_flags = 0; + save_current_sctx = current_sctx; current_sctx = fp->uf_script_ctx; save_did_emsg = did_emsg; @@ -2889,6 +2895,7 @@ call_user_func( #endif if (using_sandbox) --sandbox; + sticky_cmdmod_flags = save_sticky_cmdmod_flags; if (p_verbose >= 12 && SOURCING_NAME != NULL) {