Skip to content

Commit 0fe937f

Browse files
committed
patch 8.2.0991: cannot get window type for autocmd and preview window
Problem: Cannot get window type for autocmd and preview window. Solution: Add types to win_gettype(). (Yegappan Lakshmanan, closes vim#6277)
1 parent a1bc6f1 commit 0fe937f

File tree

5 files changed

+36
-3
lines changed

5 files changed

+36
-3
lines changed

runtime/doc/eval.txt

+3
Original file line numberDiff line numberDiff line change
@@ -10864,7 +10864,10 @@ win_getid([{win} [, {tab}]]) *win_getid()*
1086410864

1086510865
win_gettype([{nr}]) *win_gettype()*
1086610866
Return the type of the window:
10867+
"aucmdwin" autocommand window. Temporary window
10868+
used to execute autocommands.
1086710869
"popup" popup window |popup|
10870+
"preview" preview window |preview-window|
1086810871
"command" command-line window |cmdwin|
1086910872
(empty) normal window
1087010873
"unknown" window {nr} not found

src/evalwindow.c

+8-3
Original file line numberDiff line numberDiff line change
@@ -858,13 +858,18 @@ f_win_gettype(typval_T *argvars, typval_T *rettv)
858858
return;
859859
}
860860
}
861+
if (wp == aucmd_win)
862+
rettv->vval.v_string = vim_strsave((char_u *)"aucmdwin");
863+
#if defined(FEAT_QUICKFIX)
864+
else if (wp->w_p_pvw)
865+
rettv->vval.v_string = vim_strsave((char_u *)"preview");
866+
#endif
861867
#ifdef FEAT_PROP_POPUP
862-
if (WIN_IS_POPUP(wp))
868+
else if (WIN_IS_POPUP(wp))
863869
rettv->vval.v_string = vim_strsave((char_u *)"popup");
864-
else
865870
#endif
866871
#ifdef FEAT_CMDWIN
867-
if (wp == curwin && cmdwin_type != 0)
872+
else if (wp == curwin && cmdwin_type != 0)
868873
rettv->vval.v_string = vim_strsave((char_u *)"command");
869874
#endif
870875
}

src/testdir/test_autocmd.vim

+22
Original file line numberDiff line numberDiff line change
@@ -2579,4 +2579,26 @@ func Test_BufDelete_changebuf()
25792579
close!
25802580
endfunc
25812581

2582+
" Test for the temporary internal window used to execute autocmds
2583+
func Test_autocmd_window()
2584+
%bw!
2585+
edit one.txt
2586+
tabnew two.txt
2587+
let g:blist = []
2588+
augroup aucmd_win_test
2589+
au!
2590+
au BufEnter * call add(g:blist, [expand('<afile>'),
2591+
\ win_gettype(bufwinnr(expand('<afile>')))])
2592+
augroup END
2593+
2594+
doautoall BufEnter
2595+
call assert_equal([['one.txt', 'aucmdwin'], ['two.txt', '']], g:blist)
2596+
2597+
augroup aucmd_win_test
2598+
au!
2599+
augroup END
2600+
augroup! aucmd_win_test
2601+
%bw!
2602+
endfunc
2603+
25822604
" vim: shiftwidth=2 sts=2 expandtab

src/testdir/test_preview.vim

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ func Test_window_preview()
2525
" Go to the preview window
2626
wincmd P
2727
call assert_equal(1, &previewwindow)
28+
call assert_equal('preview', win_gettype())
2829

2930
" Close preview window
3031
wincmd z

src/version.c

+2
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,8 @@ static char *(features[]) =
754754

755755
static int included_patches[] =
756756
{ /* Add new patch number below this line */
757+
/**/
758+
991,
757759
/**/
758760
990,
759761
/**/

0 commit comments

Comments
 (0)