# HG changeset patch # User Bram Moolenaar # Date 1596744905 -7200 # Node ID 60ba361a7fdb3bb68cf9a12168600d5fccbf21de # Parent a2e140e1cdbed4972f6d7884bae9ebe2161f436c patch 8.2.1382: Vim9: using :import in filetype plugin gives an error Commit: https://github.com/vim/vim/commit/8e1986e3896cc8c2a05fc6291a39ebb275e1cebf Author: Bram Moolenaar Date: Thu Aug 6 22:11:06 2020 +0200 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 https://github.com/vim/vim/issues/6636) diff --git a/src/ex_docmd.c b/src/ex_docmd.c --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -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 diff --git a/src/testdir/test_vim9_script.vim b/src/testdir/test_vim9_script.vim --- a/src/testdir/test_vim9_script.vim +++ b/src/testdir/test_vim9_script.vim @@ -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:') diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -755,6 +755,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1382, +/**/ 1381, /**/ 1380,