forked from aniani/vim
patch 8.2.4345: <amatch> is expanded like a file name for DirChangedPre
Problem: <amatch> is expanded like a file name for DirChangedPre. Solution: Do not expand <amatch>. (closes #9742) Also for the User event.
This commit is contained in:
@@ -2043,7 +2043,7 @@ apply_autocmds_group(
|
||||
{
|
||||
sfname = vim_strsave(fname);
|
||||
// Don't try expanding FileType, Syntax, FuncUndefined, WindowID,
|
||||
// ColorScheme, QuickFixCmd* or DirChanged
|
||||
// ColorScheme, QuickFixCmd*, DirChanged and similar.
|
||||
if (event == EVENT_FILETYPE
|
||||
|| event == EVENT_SYNTAX
|
||||
|| event == EVENT_CMDLINECHANGED
|
||||
@@ -2061,7 +2061,9 @@ apply_autocmds_group(
|
||||
|| event == EVENT_OPTIONSET
|
||||
|| event == EVENT_QUICKFIXCMDPOST
|
||||
|| event == EVENT_DIRCHANGED
|
||||
|| event == EVENT_DIRCHANGEDPRE
|
||||
|| event == EVENT_MODECHANGED
|
||||
|| event == EVENT_USER
|
||||
|| event == EVENT_WINCLOSED)
|
||||
{
|
||||
fname = vim_strsave(fname);
|
||||
|
@@ -1899,6 +1899,14 @@ func Test_autocommand_all_events()
|
||||
call assert_fails('au! * x bwipe', 'E1155:')
|
||||
endfunc
|
||||
|
||||
func Test_autocmd_user()
|
||||
au User MyEvent let s:res = [expand("<afile>"), expand("<amatch>")]
|
||||
doautocmd User MyEvent
|
||||
call assert_equal(['MyEvent', 'MyEvent'], s:res)
|
||||
au! User
|
||||
unlet s:res
|
||||
endfunc
|
||||
|
||||
function s:Before_test_dirchanged()
|
||||
augroup test_dirchanged
|
||||
autocmd!
|
||||
@@ -1922,11 +1930,11 @@ endfunc
|
||||
|
||||
function Test_dirchanged_global()
|
||||
call s:Before_test_dirchanged()
|
||||
autocmd test_dirchanged DirChangedPre global call add(s:li, "pre cd " .. v:event.directory)
|
||||
autocmd test_dirchanged DirChangedPre global call add(s:li, expand("<amatch>") .. " pre cd " .. v:event.directory)
|
||||
autocmd test_dirchanged DirChanged global call add(s:li, "cd:")
|
||||
autocmd test_dirchanged DirChanged global call add(s:li, expand("<afile>"))
|
||||
call chdir(s:dir_foo)
|
||||
let expected = ["pre cd " .. s:dir_foo, "cd:", s:dir_foo]
|
||||
let expected = ["global pre cd " .. s:dir_foo, "cd:", s:dir_foo]
|
||||
call assert_equal(expected, s:li)
|
||||
call chdir(s:dir_foo)
|
||||
call assert_equal(expected, s:li)
|
||||
|
@@ -746,6 +746,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
4345,
|
||||
/**/
|
||||
4344,
|
||||
/**/
|
||||
|
Reference in New Issue
Block a user