Problem: Cannot get window type for autocmd and preview window.
Solution: Add types to win_gettype(). (Yegappan Lakshmanan, closes #6277)
win_gettype([{nr}]) *win_gettype()*
Return the type of the window:
+ "aucmdwin" autocommand window. Temporary window
+ used to execute autocommands.
"popup" popup window |popup|
+ "preview" preview window |preview-window|
"command" command-line window |cmdwin|
(empty) normal window
"unknown" window {nr} not found
return;
}
}
+ if (wp == aucmd_win)
+ rettv->vval.v_string = vim_strsave((char_u *)"aucmdwin");
+#if defined(FEAT_QUICKFIX)
+ else if (wp->w_p_pvw)
+ rettv->vval.v_string = vim_strsave((char_u *)"preview");
+#endif
#ifdef FEAT_PROP_POPUP
- if (WIN_IS_POPUP(wp))
+ else if (WIN_IS_POPUP(wp))
rettv->vval.v_string = vim_strsave((char_u *)"popup");
- else
#endif
#ifdef FEAT_CMDWIN
- if (wp == curwin && cmdwin_type != 0)
+ else if (wp == curwin && cmdwin_type != 0)
rettv->vval.v_string = vim_strsave((char_u *)"command");
#endif
}
close!
endfunc
+" Test for the temporary internal window used to execute autocmds
+func Test_autocmd_window()
+ %bw!
+ edit one.txt
+ tabnew two.txt
+ let g:blist = []
+ augroup aucmd_win_test
+ au!
+ au BufEnter * call add(g:blist, [expand('<afile>'),
+ \ win_gettype(bufwinnr(expand('<afile>')))])
+ augroup END
+
+ doautoall BufEnter
+ call assert_equal([['one.txt', 'aucmdwin'], ['two.txt', '']], g:blist)
+
+ augroup aucmd_win_test
+ au!
+ augroup END
+ augroup! aucmd_win_test
+ %bw!
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
" Go to the preview window
wincmd P
call assert_equal(1, &previewwindow)
+ call assert_equal('preview', win_gettype())
" Close preview window
wincmd z
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 991,
/**/
990,
/**/