To: vim_dev@googlegroups.com Subject: Patch 8.2.4192 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.4192 Problem: Cannot use an import in 'printexpr'. Solution: Set the script context when evaluating 'printexpr'. Files: src/evalvars.c, src/testdir/test_vim9_import.vim *** ../vim-8.2.4191/src/evalvars.c 2022-01-22 20:55:26.548785095 +0000 --- src/evalvars.c 2022-01-23 13:40:55.750382441 +0000 *************** *** 391,403 **** --- 391,411 ---- eval_printexpr(char_u *fname, char_u *args) { int err = FALSE; + sctx_T saved_sctx = current_sctx; + sctx_T *ctx; set_vim_var_string(VV_FNAME_IN, fname, -1); set_vim_var_string(VV_CMDARG, args, -1); + ctx = get_option_sctx("printexpr"); + if (ctx != NULL) + current_sctx = *ctx; + if (eval_to_bool(p_pexpr, &err, NULL, FALSE)) err = TRUE; + set_vim_var_string(VV_FNAME_IN, NULL, -1); set_vim_var_string(VV_CMDARG, NULL, -1); + current_sctx = saved_sctx; if (err) { *** ../vim-8.2.4191/src/testdir/test_vim9_import.vim 2022-01-22 20:55:26.548785095 +0000 --- src/testdir/test_vim9_import.vim 2022-01-23 13:41:34.253612364 +0000 *************** *** 874,879 **** --- 874,910 ---- delete('Xindenter') enddef + func Test_import_in_printexpr() + CheckFeature postscript + call Run_Test_import_in_printexpr() + endfunc + + def Run_Test_import_in_printexpr() + var lines =<< trim END + vim9script + export def PrintFile(): bool + g:printed = 'yes' + delete('v:fname_in') + return false + enddef + END + writefile(lines, 'Xprint.vim') + + lines =<< trim END + vim9script + import './Xprint.vim' + set printexpr=Xprint.PrintFile() + END + CheckScriptSuccess(lines) + + help + hardcopy dummy args + assert_equal('yes', g:printed) + + delete('Xprint.vim') + set printexpr= + enddef + def Test_export_fails() CheckScriptFailure(['export var some = 123'], 'E1042:') CheckScriptFailure(['vim9script', 'export var g:some'], 'E1022:') *** ../vim-8.2.4191/src/version.c 2022-01-23 13:05:36.303210322 +0000 --- src/version.c 2022-01-23 13:33:55.794810498 +0000 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 4192, /**/ -- Sorry, no fortune today. /// 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 ///