summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/autocmd.c3
-rw-r--r--src/testdir/test_autocmd.vim26
-rw-r--r--src/version.c2
3 files changed, 31 insertions, 0 deletions
diff --git a/src/autocmd.c b/src/autocmd.c
index bce57cb759..8380f8a04e 100644
--- a/src/autocmd.c
+++ b/src/autocmd.c
@@ -3391,6 +3391,9 @@ f_autocmd_get(typval_T *argvars, typval_T *rettv)
{
char_u *group_name;
+ if (ap->pat == NULL) // pattern has been removed
+ continue;
+
if (group != AUGROUP_ALL && group != ap->group)
continue;
diff --git a/src/testdir/test_autocmd.vim b/src/testdir/test_autocmd.vim
index 24e1daf77a..c9f257a87c 100644
--- a/src/testdir/test_autocmd.vim
+++ b/src/testdir/test_autocmd.vim
@@ -4024,6 +4024,32 @@ func Test_autocmd_get()
\ event: 'BufAdd', pattern: '*.abc'}))
call assert_equal([], autocmd_get(#{group: 'TestAutoCmdFns',
\ event: 'BufWipeout'}))
+
+ " Test for getting autocmds after removing one inside an autocmd
+ func CheckAutocmdGet()
+ augroup TestAutoCmdFns
+ autocmd! BufAdd *.vim
+ augroup END
+
+ let expected = [
+ \ #{cmd: 'echo "bufadd-py"', group: 'TestAutoCmdFns',
+ \ pattern: '*.py', nested: v:false, once: v:false,
+ \ event: 'BufAdd'},
+ \ #{cmd: 'echo "bufhidden"', group: 'TestAutoCmdFns',
+ \ pattern: '*.vim', nested: v:false,
+ \ once: v:false, event: 'BufHidden'}]
+
+ call assert_equal(expected, autocmd_get(#{group: 'TestAutoCmdFns'}))
+ call assert_equal([expected[0]],
+ \ autocmd_get(#{group: 'TestAutoCmdFns', pattern: '*.py'}))
+ call assert_equal([expected[1]],
+ \ autocmd_get(#{group: 'TestAutoCmdFns', pattern: '*.vim'}))
+ endfunc
+
+ autocmd User Xauget call CheckAutocmdGet()
+ doautocmd User Xauget
+ autocmd! User Xauget
+
call assert_fails("call autocmd_get(#{group: 'abc', event: 'BufAdd'})",
\ 'E367:')
let cmd = "echo autocmd_get(#{group: 'TestAutoCmdFns', event: 'abc'})"
diff --git a/src/version.c b/src/version.c
index 50a34c8c79..40186dd500 100644
--- a/src/version.c
+++ b/src/version.c
@@ -705,6 +705,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 471,
+/**/
470,
/**/
469,