diff src/testdir/test_vim9_script.vim @ 21652:befb512e0762 v8.2.1376

patch 8.2.1376: Vim9: expression mapping causes error for using :import Commit: https://github.com/vim/vim/commit/803af686e23c7bb17273bb0c78ff0bf97e8d23f4 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Aug 5 16:20:03 2020 +0200 patch 8.2.1376: Vim9: expression mapping causes error for using :import Problem: Vim9: expression mapping causes error for using :import. Solution: Add EX_LOCK_OK to :import and :export. (closes 3606)
author Bram Moolenaar <Bram@vim.org>
date Wed, 05 Aug 2020 16:30:03 +0200
parents 33fec2448697
children 60ba361a7fdb
line wrap: on
line diff
--- a/src/testdir/test_vim9_script.vim
+++ b/src/testdir/test_vim9_script.vim
@@ -1351,6 +1351,36 @@ def Test_vim9_import_export()
   delete('Xvim9_script')
 enddef
 
+func g:Trigger()
+  source Ximport.vim
+  return "echo 'yes'\<CR>"
+endfunc
+
+def Test_import_export_expr_map()
+  # check that :import and :export work when buffer is locked
+  let export_lines =<< trim END
+    vim9script
+    export def That(): string
+      return 'yes'
+    enddef
+  END
+  writefile(export_lines, 'Xexport_that.vim')
+
+  let import_lines =<< trim END
+    vim9script
+    import That from './Xexport_that.vim'
+    assert_equal('yes', That())
+  END
+  writefile(import_lines, 'Ximport.vim')
+
+  nnoremap <expr> trigger g:Trigger()
+  feedkeys('trigger', "xt")
+
+  delete('Xexport.vim')
+  delete('Ximport.vim')
+  nunmap trigger
+enddef
+
 def Test_vim9script_fails()
   CheckScriptFailure(['scriptversion 2', 'vim9script'], 'E1039:')
   CheckScriptFailure(['vim9script', 'scriptversion 2'], 'E1040:')