To: vim_dev@googlegroups.com Subject: Patch 8.2.4186 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.4186 Problem: Cannot use an import in 'patchexpr'. Solution: Set the script context when evaluating 'patchexpr'. Do not require 'patchexpr' to return a bool, it was ignored anyway. Files: src/evalvars.c, src/testdir/test_vim9_import.vim *** ../vim-8.2.4185/src/evalvars.c 2022-01-22 18:21:32.919197886 +0000 --- src/evalvars.c 2022-01-22 20:52:50.479797903 +0000 *************** *** 443,457 **** char_u *difffile, char_u *outfile) { ! int err; set_vim_var_string(VV_FNAME_IN, origfile, -1); set_vim_var_string(VV_FNAME_DIFF, difffile, -1); set_vim_var_string(VV_FNAME_OUT, outfile, -1); ! (void)eval_to_bool(p_pex, &err, NULL, FALSE); set_vim_var_string(VV_FNAME_IN, NULL, -1); set_vim_var_string(VV_FNAME_DIFF, NULL, -1); set_vim_var_string(VV_FNAME_OUT, NULL, -1); } # endif --- 443,468 ---- char_u *difffile, char_u *outfile) { ! sctx_T saved_sctx = current_sctx; ! sctx_T *ctx; ! typval_T *tv; set_vim_var_string(VV_FNAME_IN, origfile, -1); set_vim_var_string(VV_FNAME_DIFF, difffile, -1); set_vim_var_string(VV_FNAME_OUT, outfile, -1); ! ! ctx = get_option_sctx("patchexpr"); ! if (ctx != NULL) ! current_sctx = *ctx; ! ! // errors are ignored ! tv = eval_expr(p_pex, NULL); ! free_tv(tv); ! set_vim_var_string(VV_FNAME_IN, NULL, -1); set_vim_var_string(VV_FNAME_DIFF, NULL, -1); set_vim_var_string(VV_FNAME_OUT, NULL, -1); + current_sctx = saved_sctx; } # endif *** ../vim-8.2.4185/src/testdir/test_vim9_import.vim 2022-01-22 20:31:56.315870158 +0000 --- src/testdir/test_vim9_import.vim 2022-01-22 20:52:26.208265747 +0000 *************** *** 759,764 **** --- 759,794 ---- bwipe! enddef + def Test_import_in_patchexpr() + var lines =<< trim END + vim9script + export def TPatch() + call writefile(['output file'], v:fname_out) + enddef + END + writefile(lines, 'Xpatchexpr') + + lines =<< trim END + vim9script + import './Xpatchexpr' as patch + set patchexpr=patch.TPatch() + END + CheckScriptSuccess(lines) + + call writefile(['input file'], 'Xinput') + call writefile(['diff file'], 'Xdiff') + :%bwipe! + edit Xinput + diffpatch Xdiff + call assert_equal('output file', getline(1)) + + call delete('Xinput') + call delete('Xdiff') + call delete('Xpatchexpr') + set patchexpr& + :%bwipe! + enddef + def Test_import_in_formatexpr() var lines =<< trim END vim9script *** ../vim-8.2.4185/src/version.c 2022-01-22 20:31:56.319870079 +0000 --- src/version.c 2022-01-22 20:55:17.448960981 +0000 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 4186, /**/ -- LAUNCELOT: Isn't there a St. Aaaaarrrrrrggghhh's in Cornwall? ARTHUR: No, that's Saint Ives. "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// 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 ///