diff src/testdir/test_vim9_import.vim @ 27328:7382135dac01 v8.2.4192

patch 8.2.4192: cannot use an import in 'printexpr' Commit: https://github.com/vim/vim/commit/7ef4a2fe3736bbeb5bad182782a74576aa06b0db Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jan 23 13:44:35 2022 +0000 patch 8.2.4192: cannot use an import in 'printexpr' Problem: Cannot use an import in 'printexpr'. Solution: Set the script context when evaluating 'printexpr'.
author Bram Moolenaar <Bram@vim.org>
date Sun, 23 Jan 2022 14:45:03 +0100
parents a195a900a329
children aeadf4315bef
line wrap: on
line diff
--- a/src/testdir/test_vim9_import.vim
+++ b/src/testdir/test_vim9_import.vim
@@ -874,6 +874,37 @@ def Test_import_in_indentexpr()
   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:')