Mercurial > vim
changeset 20879:0ab45b558621 v8.2.0991
patch 8.2.0991: cannot get window type for autocmd and preview window
Commit: https://github.com/vim/vim/commit/0fe937fd8616fcd24b1b1ef2ab9f1657615dd22c
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Jun 16 22:42:04 2020 +0200
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 https://github.com/vim/vim/issues/6277)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 16 Jun 2020 22:45:04 +0200 |
parents | 393f830e4f16 |
children | 038888dff2a1 |
files | runtime/doc/eval.txt src/evalwindow.c src/testdir/test_autocmd.vim src/testdir/test_preview.vim src/version.c |
diffstat | 5 files changed, 36 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -10864,7 +10864,10 @@ win_getid([{win} [, {tab}]]) *win_get 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
--- a/src/evalwindow.c +++ b/src/evalwindow.c @@ -858,13 +858,18 @@ f_win_gettype(typval_T *argvars, typval_ 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 }
--- a/src/testdir/test_autocmd.vim +++ b/src/testdir/test_autocmd.vim @@ -2579,4 +2579,26 @@ func Test_BufDelete_changebuf() 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