To: vim_dev@googlegroups.com Subject: Patch 8.2.4181 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.4181 Problem: Vim9: cannot use an import in 'diffexpr'. Solution: Set the script context when evaluating 'diffexpr'. Do not require 'diffexpr' to return a bool, it was ignored anyway. Files: src/evalvars.c, src/testdir/test_vim9_import.vim *** ../vim-8.2.4180/src/evalvars.c 2022-01-21 13:29:52.479888865 +0000 --- src/evalvars.c 2022-01-22 17:52:08.188354347 +0000 *************** *** 415,429 **** char_u *newfile, char_u *outfile) { ! int err = FALSE; set_vim_var_string(VV_FNAME_IN, origfile, -1); set_vim_var_string(VV_FNAME_NEW, newfile, -1); set_vim_var_string(VV_FNAME_OUT, outfile, -1); ! (void)eval_to_bool(p_dex, &err, NULL, FALSE); set_vim_var_string(VV_FNAME_IN, NULL, -1); set_vim_var_string(VV_FNAME_NEW, NULL, -1); set_vim_var_string(VV_FNAME_OUT, NULL, -1); } void --- 415,440 ---- char_u *newfile, 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_NEW, newfile, -1); set_vim_var_string(VV_FNAME_OUT, outfile, -1); ! ! ctx = get_option_sctx("diffexpr"); ! if (ctx != NULL) ! current_sctx = *ctx; ! ! // errors are ignored ! tv = eval_expr(p_dex, NULL); ! clear_tv(tv); ! set_vim_var_string(VV_FNAME_IN, NULL, -1); set_vim_var_string(VV_FNAME_NEW, NULL, -1); set_vim_var_string(VV_FNAME_OUT, NULL, -1); + current_sctx = saved_sctx; } void *** ../vim-8.2.4180/src/testdir/test_vim9_import.vim 2022-01-22 13:39:04.103476264 +0000 --- src/testdir/test_vim9_import.vim 2022-01-22 17:51:28.417271061 +0000 *************** *** 716,721 **** --- 716,764 ---- &rtp = save_rtp enddef + func Test_import_in_diffexpr() + CheckExecutable diff + + call Run_Test_import_in_diffexpr() + endfunc + + def Run_Test_import_in_diffexpr() + var lines =<< trim END + vim9script + + export def DiffExpr() + # Prepend some text to check diff type detection + writefile(['warning', ' message'], v:fname_out) + silent exe '!diff ' .. v:fname_in .. ' ' + .. v:fname_new .. '>>' .. v:fname_out + enddef + END + writefile(lines, 'Xdiffexpr') + + lines =<< trim END + vim9script + import './Xdiffexpr' as diff + + set diffexpr=diff.DiffExpr() + set diffopt=foldcolumn:0 + END + CheckScriptSuccess(lines) + + enew! + call setline(1, ['one', 'two', 'three']) + diffthis + + botright vert new + call setline(1, ['one', 'two', 'three.']) + diffthis + # we only check if this does not cause errors + redraw + + diffoff! + bwipe! + bwipe! + enddef + def Test_export_fails() CheckScriptFailure(['export var some = 123'], 'E1042:') CheckScriptFailure(['vim9script', 'export var g:some'], 'E1022:') *** ../vim-8.2.4180/src/version.c 2022-01-22 15:09:32.497898745 +0000 --- src/version.c 2022-01-22 17:33:20.183699090 +0000 *************** *** 752,753 **** --- 752,755 ---- { /* Add new patch number below this line */ + /**/ + 4181, /**/ -- ARTHUR: What does it say? BROTHER MAYNARD: It reads ... "Here may be found the last words of Joseph of Aramathea." "He who is valorous and pure of heart may find the Holy Grail in the aaaaarrrrrrggghhh..." ARTHUR: What? BROTHER MAYNARD: "The Aaaaarrrrrrggghhh..." "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 ///