diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-01-21 16:31:11 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-01-21 16:31:11 +0000 |
commit | e70dd11ef41f69bd5e94f630194e6b3c4f3f2102 (patch) | |
tree | 52b2b8861caa9630a3dcd58e9f217a1b675515e7 /src/testdir/test_vim9_import.vim | |
parent | 6517f14165cdebf83a07ab9d4aeeb102b4e16e92 (diff) |
patch 8.2.4173: cannot use an import in 'foldexpr'v8.2.4173
Problem: Cannot use an import in 'foldexpr'.
Solution: Set the script context to where 'foldexpr' was set. (closes #9584)
Fix that the script context was not set for all buffers.
Diffstat (limited to 'src/testdir/test_vim9_import.vim')
-rw-r--r-- | src/testdir/test_vim9_import.vim | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/testdir/test_vim9_import.vim b/src/testdir/test_vim9_import.vim index 6e61d07189..6ecea56a93 100644 --- a/src/testdir/test_vim9_import.vim +++ b/src/testdir/test_vim9_import.vim @@ -673,6 +673,45 @@ def Test_use_autoload_import_in_insert_completion() &rtp = save_rtp enddef +def Test_use_autoload_import_in_fold_expression() + mkdir('Xdir/autoload', 'p') + var save_rtp = &rtp + exe 'set rtp^=' .. getcwd() .. '/Xdir' + + var lines =<< trim END + vim9script + export def Expr(): string + return getline(v:lnum) =~ '^#' ? '>1' : '1' + enddef + g:fold_loaded = 'yes' + END + writefile(lines, 'Xdir/autoload/fold.vim') + + lines =<< trim END + vim9script + import autoload 'fold.vim' + &foldexpr = 'fold.Expr()' + &foldmethod = 'expr' + &debug = 'throw' + END + new + setline(1, ['# one', 'text', '# two', 'text']) + g:fold_loaded = 'no' + CheckScriptSuccess(lines) + assert_equal('no', g:fold_loaded) + redraw + assert_equal('yes', g:fold_loaded) + + # Check that script context of 'foldexpr' is copied to another buffer. + edit! otherfile + redraw + + set foldexpr= foldmethod& + bwipe! + delete('Xdir', 'rf') + &rtp = save_rtp +enddef + def Test_export_fails() CheckScriptFailure(['export var some = 123'], 'E1042:') CheckScriptFailure(['vim9script', 'export var g:some'], 'E1022:') |