diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-02-11 16:30:12 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-02-11 16:30:12 +0000 |
commit | f6246f51e3d85a982a899b4a8fd9045a5e23016f (patch) | |
tree | 9c4d6c203fb5aa0703bf5055d612e27b82d35cef | |
parent | 14f23122bf94d0d835bed6f0bd0d17b3e47441ab (diff) | |
download | vim-git-f6246f51e3d85a982a899b4a8fd9045a5e23016f.tar.gz |
patch 8.2.4345: <amatch> is expanded like a file name for DirChangedPrev8.2.4345
Problem: <amatch> is expanded like a file name for DirChangedPre.
Solution: Do not expand <amatch>. (closes #9742) Also for the User event.
-rw-r--r-- | src/autocmd.c | 4 | ||||
-rw-r--r-- | src/testdir/test_autocmd.vim | 12 | ||||
-rw-r--r-- | src/version.c | 2 |
3 files changed, 15 insertions, 3 deletions
diff --git a/src/autocmd.c b/src/autocmd.c index 97b27effd..d1ecad944 100644 --- a/src/autocmd.c +++ b/src/autocmd.c @@ -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); diff --git a/src/testdir/test_autocmd.vim b/src/testdir/test_autocmd.vim index 3ff4c3cf5..d3c9b8902 100644 --- a/src/testdir/test_autocmd.vim +++ b/src/testdir/test_autocmd.vim @@ -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) diff --git a/src/version.c b/src/version.c index 2c86de33e..b70fb291a 100644 --- a/src/version.c +++ b/src/version.c @@ -747,6 +747,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 4345, +/**/ 4344, /**/ 4343, |