Skip to content

Commit de653f0

Browse files
committed
patch 7.4.2314
Problem: No error when deleting an augroup while it's the current one. Solution: Disallow deleting an augroup when it's the current one.
1 parent b62cc36 commit de653f0

3 files changed

Lines changed: 11 additions & 3 deletions

File tree

src/fileio.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8017,6 +8017,8 @@ au_del_group(char_u *name)
80178017
i = au_find_group(name);
80188018
if (i == AUGROUP_ERROR) /* the group doesn't exist */
80198019
EMSG2(_("E367: No such group: \"%s\""), name);
8020+
else if (i == current_augroup)
8021+
EMSG(_("E936: Cannot delete the current group"));
80208022
else
80218023
{
80228024
event_T event;

src/testdir/test_autocmd.vim

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,13 +182,17 @@ func Test_augroup_warning()
182182
doautocmd VimEnter
183183
redir END
184184
call assert_true(match(res, "W19:") < 0)
185+
au! VimEnter
185186
endfunc
186187

187188
func Test_augroup_deleted()
188-
" This caused a crash
189+
" This caused a crash before E936 was introduced
189190
augroup x
191+
call assert_fails('augroup! x', 'E936:')
192+
au VimEnter * echo
193+
augroup end
190194
augroup! x
191-
au VimEnter * echo
192-
au VimEnter
195+
call assert_true(match(execute('au VimEnter'), "-Deleted-.*VimEnter") >= 0)
196+
au! VimEnter
193197
endfunc
194198

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,8 @@ static char *(features[]) =
763763

764764
static int included_patches[] =
765765
{ /* Add new patch number below this line */
766+
/**/
767+
2314,
766768
/**/
767769
2313,
768770
/**/

0 commit comments

Comments
 (0)