]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.2.0991: cannot get window type for autocmd and preview window v8.2.0991
authorBram Moolenaar <Bram@vim.org>
Tue, 16 Jun 2020 20:42:04 +0000 (22:42 +0200)
committerBram Moolenaar <Bram@vim.org>
Tue, 16 Jun 2020 20:42:04 +0000 (22:42 +0200)
Problem:    Cannot get window type for autocmd and preview window.
Solution:   Add types to win_gettype(). (Yegappan Lakshmanan, closes #6277)

runtime/doc/eval.txt
src/evalwindow.c
src/testdir/test_autocmd.vim
src/testdir/test_preview.vim
src/version.c

index 4ab8bbd1ee03e05997d656dd82d55667ae9310b5..fe2e94e258593d9bbb8abcfb9ff6f9b55d07511c 100644 (file)
@@ -10864,7 +10864,10 @@ win_getid([{win} [, {tab}]])                           *win_getid()*
 
 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
index 0db45bc9c242fa2d2925e9fee4e8cdab021fd24a..585ff729f344619b8e5fa9e295804a8fac327234 100644 (file)
@@ -858,13 +858,18 @@ f_win_gettype(typval_T *argvars, typval_T *rettv)
            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
 }
index ffeaecac00865596f9ba58115033201dabe20aff..285d9943642031d5edeeb2b505120e64b6c07fc0 100644 (file)
@@ -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
index 628ad2bfb4aedb21868dc22fc13b5f2a16d74b7d..1bf1d3f8be25bafec795d7e66b1c19ce551b4061 100644 (file)
@@ -25,6 +25,7 @@ func Test_window_preview()
   " Go to the preview window
   wincmd P
   call assert_equal(1, &previewwindow)
+  call assert_equal('preview', win_gettype())
 
   " Close preview window
   wincmd z
index 57b092a370ae1875757bac8ae0dc33e09e2cf017..9df09d1f9052ed1f85f03ac2205545af20a73e37 100644 (file)
@@ -754,6 +754,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    991,
 /**/
     990,
 /**/