]> granicus.if.org Git - vim/commitdiff
patch 8.2.1382: Vim9: using :import in filetype plugin gives an error v8.2.1382
authorBram Moolenaar <Bram@vim.org>
Thu, 6 Aug 2020 20:11:06 +0000 (22:11 +0200)
committerBram Moolenaar <Bram@vim.org>
Thu, 6 Aug 2020 20:11:06 +0000 (22:11 +0200)
Problem:    Vim9: using :import in filetype plugin gives an error.
Solution:   Allow commands with the EX_LOCK_OK flag. (closes #6636)

src/ex_docmd.c
src/testdir/test_vim9_script.vim
src/version.c

index 105710b01605b628c12037ae0518bbc66dfec178..96eac7fbe489b06df97117c4d59caca43ed87468 100644 (file)
@@ -2087,7 +2087,7 @@ do_one_cmd(
        // Do allow ":checktime" (it is postponed).
        // Do allow ":edit" (check for an argument later).
        // Do allow ":file" with no arguments (check for an argument later).
-       if (!(ea.argt & EX_CMDWIN)
+       if (!(ea.argt & (EX_CMDWIN | EX_LOCK_OK))
                && ea.cmdidx != CMD_checktime
                && ea.cmdidx != CMD_edit
                && ea.cmdidx != CMD_file
index b05cd54ebbe166b079c9770101c977a394d92b8d..e5d5e872d86732d473ddae87b6c07c27442b7797 100644 (file)
@@ -1381,6 +1381,36 @@ def Test_import_export_expr_map()
   nunmap trigger
 enddef
 
+def Test_import_in_filetype()
+  # check that :import works when the buffer is locked
+  mkdir('ftplugin', 'p')
+  let export_lines =<< trim END
+    vim9script
+    export let That = 'yes'
+  END
+  writefile(export_lines, 'ftplugin/Xexport_that.vim')
+
+  let import_lines =<< trim END
+    vim9script
+    import That from './Xexport_that.vim'
+    assert_equal('yes', That)
+    g:did_load_mytpe = 1
+  END
+  writefile(import_lines, 'ftplugin/qf.vim')
+
+  let save_rtp = &rtp
+  &rtp = getcwd() .. ',' .. &rtp
+
+  filetype plugin on
+  copen
+  assert_equal(1, g:did_load_mytpe)
+
+  quit!
+  delete('Xexport.vim')
+  delete('ftplugin', 'rf')
+  &rtp = save_rtp
+enddef
+
 def Test_vim9script_fails()
   CheckScriptFailure(['scriptversion 2', 'vim9script'], 'E1039:')
   CheckScriptFailure(['vim9script', 'scriptversion 2'], 'E1040:')
index 3d7c5b129bf78bbe705c04fc5cef8ef73c94866f..5c745df6652e728c34f0dd6a133dea2ee42c72cd 100644 (file)
@@ -754,6 +754,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1382,
 /**/
     1381,
 /**/