To: vim_dev@googlegroups.com Subject: Patch 9.0.0140 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 9.0.0140 Problem: execute() does not use the "legacy" command modifier. Solution: pass the command modifier in sticky_cmdmod_flags. (Kota Kato, closes #10845) Files: src/evalfunc.c, src/testdir/test_vim9_cmd.vim *** ../vim-9.0.0139/src/evalfunc.c 2022-07-30 15:43:56.222091886 +0100 --- src/evalfunc.c 2022-08-04 18:46:14.414608001 +0100 *************** *** 3929,3934 **** --- 3929,3935 ---- int save_redir_off = redir_off; garray_T save_ga; int save_msg_col = msg_col; + int save_sticky_cmdmod_flags = sticky_cmdmod_flags; int echo_output = FALSE; rettv->vval.v_string = NULL; *************** *** 3985,3990 **** --- 3986,3994 ---- if (!echo_output) msg_col = 0; // prevent leading spaces + // For "legacy call execute('cmd')" and "vim9cmd execute('cmd')" apply the + // command modifiers to "cmd". + sticky_cmdmod_flags = cmdmod.cmod_flags & (CMOD_LEGACY | CMOD_VIM9CMD); if (cmd != NULL) do_cmdline_cmd(cmd); else *************** *** 3997,4002 **** --- 4001,4007 ---- DOCMD_NOWAIT|DOCMD_VERBOSE|DOCMD_REPEAT|DOCMD_KEYTYPED); --list->lv_refcount; } + sticky_cmdmod_flags = save_sticky_cmdmod_flags; // Need to append a NUL to the result. if (ga_grow(&redir_execute_ga, 1) == OK) *** ../vim-9.0.0139/src/testdir/test_vim9_cmd.vim 2022-05-21 15:15:44.000000000 +0100 --- src/testdir/test_vim9_cmd.vim 2022-08-04 18:49:09.082697284 +0100 *************** *** 142,147 **** --- 142,183 ---- END v9.CheckScriptSuccess(lines) delfunc g:TheFunc + + # vim9cmd execute(cmd) executes code in vim9 script context + lines =<< trim END + vim9cmd execute("g:vim9executetest = 'bar'") + call assert_equal('bar', g:vim9executetest) + END + v9.CheckScriptSuccess(lines) + unlet g:vim9executetest + + lines =<< trim END + vim9cmd execute(["g:vim9executetest1 = 'baz'", "g:vim9executetest2 = 'foo'"]) + call assert_equal('baz', g:vim9executetest1) + call assert_equal('foo', g:vim9executetest2) + END + v9.CheckScriptSuccess(lines) + unlet g:vim9executetest1 + unlet g:vim9executetest2 + + # legacy call execute(cmd) executes code in vim script context + lines =<< trim END + vim9script + legacy call execute("let g:vim9executetest = 'bar'") + assert_equal('bar', g:vim9executetest) + END + v9.CheckScriptSuccess(lines) + unlet g:vim9executetest + + lines =<< trim END + vim9script + legacy call execute(["let g:vim9executetest1 = 'baz'", "let g:vim9executetest2 = 'foo'"]) + assert_equal('baz', g:vim9executetest1) + assert_equal('foo', g:vim9executetest2) + END + v9.CheckScriptSuccess(lines) + unlet g:vim9executetest1 + unlet g:vim9executetest2 enddef def Test_edit_wildcards() *** ../vim-9.0.0139/src/version.c 2022-08-04 15:03:16.257142097 +0100 --- src/version.c 2022-08-04 18:42:30.798252230 +0100 *************** *** 737,738 **** --- 737,740 ---- { /* Add new patch number below this line */ + /**/ + 140, /**/ -- Marriage isn't a word. It's a sentence. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///