diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-01-22 17:58:13 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-01-22 17:58:13 +0000 |
commit | 7b29f6a3949743914f08410b6f6bd6237c2f2038 (patch) | |
tree | 21b717dfe0bc0e3696c7e089381845e27c2ed62c /src/testdir/test_vim9_import.vim | |
parent | 5600a709f453045c80f92087acc0f855b4af377a (diff) |
patch 8.2.4181: Vim9: cannot use an import in 'diffexpr'v8.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.
Diffstat (limited to 'src/testdir/test_vim9_import.vim')
-rw-r--r-- | src/testdir/test_vim9_import.vim | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/testdir/test_vim9_import.vim b/src/testdir/test_vim9_import.vim index 3608802b19..e6d9728960 100644 --- a/src/testdir/test_vim9_import.vim +++ b/src/testdir/test_vim9_import.vim @@ -716,6 +716,49 @@ def Test_use_autoload_import_in_fold_expression() &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:') |