patch 8.2.1382: Vim9: using :import in filetype plugin gives an error
Problem: Vim9: using :import in filetype plugin gives an error.
Solution: Allow commands with the EX_LOCK_OK flag. (closes #6636)
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
index 105710b..96eac7f 100644
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -2087,7 +2087,7 @@
// 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
diff --git a/src/testdir/test_vim9_script.vim b/src/testdir/test_vim9_script.vim
index b05cd54..e5d5e87 100644
--- a/src/testdir/test_vim9_script.vim
+++ b/src/testdir/test_vim9_script.vim
@@ -1381,6 +1381,36 @@
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:')
diff --git a/src/version.c b/src/version.c
index 3d7c5b1..5c745df 100644
--- a/src/version.c
+++ b/src/version.c
@@ -755,6 +755,8 @@
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1382,
+/**/
1381,
/**/
1380,