int need_hide;
buf_T *buf = win->w_buffer;
+ // Never close the autocommand window.
+ if (win == aucmd_win)
+ {
+ emsg(_(e_autocmd_close));
+ return;
+ }
+
need_hide = (bufIsChanged(buf) && buf->b_nwindows <= 1);
if (need_hide && !buf_hide(buf) && !forceit)
{
#endif
EXTERN char e_dirnotf[] INIT(= N_("E919: Directory not found in '%s': \"%s\""));
EXTERN char e_au_recursive[] INIT(= N_("E952: Autocommand caused recursive behavior"));
+EXTERN char e_autocmd_close[] INIT(= N_("E813: Cannot close autocmd or popup window"));
#ifdef FEAT_MENU
EXTERN char e_menuothermode[] INIT(= N_("E328: Menu only exists in another mode"));
#endif
au!
augroup END
augroup! aucmd_win_test2
- %bw!
+ %bwipe!
+endfunc
+
+" Test for trying to close the tab that has the temporary window for exeucing
+" an autocmd.
+func Test_close_autocmd_tab()
+ edit one.txt
+ tabnew two.txt
+ augroup aucmd_win_test
+ au!
+ au BufEnter * if expand('<afile>') == 'one.txt' | tabfirst | tabonly | endif
+ augroup END
+
+ call assert_fails('doautoall BufEnter', 'E813:')
+
+ tabonly
+ augroup aucmd_win_test
+ au!
+ augroup END
+ augroup! aucmd_win_test
+ %bwipe!
endfunc
" vim: shiftwidth=2 sts=2 expandtab
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 1059,
/**/
1058,
/**/
return FAIL; // window is already being closed
if (win_unlisted(win))
{
- emsg(_("E813: Cannot close autocmd or popup window"));
+ emsg(_(e_autocmd_close));
return FAIL;
}
if ((firstwin == aucmd_win || lastwin == aucmd_win) && one_window())