mirror of
https://github.com/neovim/neovim.git
synced 2025-10-05 17:36:29 +00:00
vim-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/vim#6277)
0fe937fd86
Cherry-pick test_preview.vim,test_window_cmd.vim changes
from patch v8.2.0522.
This commit is contained in:
@@ -9280,7 +9280,10 @@ win_getid([{win} [, {tab}]]) *win_getid()*
|
|||||||
|
|
||||||
win_gettype([{nr}]) *win_gettype()*
|
win_gettype([{nr}]) *win_gettype()*
|
||||||
Return the type of the window:
|
Return the type of the window:
|
||||||
|
"aucmdwin" autocommand window. Temporary window
|
||||||
|
used to execute autocommands.
|
||||||
"popup" popup window |popup|
|
"popup" popup window |popup|
|
||||||
|
"preview" preview window |preview-window|
|
||||||
"command" command-line window |cmdwin|
|
"command" command-line window |cmdwin|
|
||||||
(empty) normal window
|
(empty) normal window
|
||||||
"unknown" window {nr} not found
|
"unknown" window {nr} not found
|
||||||
|
@@ -11006,7 +11006,11 @@ static void f_win_gettype(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (wp->w_floating) {
|
if (wp == aucmd_win) {
|
||||||
|
rettv->vval.v_string = vim_strsave((char_u *)"aucmdwin");
|
||||||
|
} else if (wp->w_p_pvw) {
|
||||||
|
rettv->vval.v_string = vim_strsave((char_u *)"preview");
|
||||||
|
} else if (wp->w_floating) {
|
||||||
rettv->vval.v_string = vim_strsave((char_u *)"popup");
|
rettv->vval.v_string = vim_strsave((char_u *)"popup");
|
||||||
} else if (wp == curwin && cmdwin_type != 0) {
|
} else if (wp == curwin && cmdwin_type != 0) {
|
||||||
rettv->vval.v_string = vim_strsave((char_u *)"command");
|
rettv->vval.v_string = vim_strsave((char_u *)"command");
|
||||||
|
@@ -1934,4 +1934,26 @@ func Test_autocmd_sigusr1()
|
|||||||
unlet g:sigusr1_passed
|
unlet g:sigusr1_passed
|
||||||
endfunc
|
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
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
@@ -11,3 +11,47 @@ func Test_Psearch()
|
|||||||
call assert_equal(wincount, winnr('$'))
|
call assert_equal(wincount, winnr('$'))
|
||||||
bwipe
|
bwipe
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_window_preview()
|
||||||
|
" Open a preview window
|
||||||
|
pedit Xa
|
||||||
|
call assert_equal(2, winnr('$'))
|
||||||
|
call assert_equal(0, &previewwindow)
|
||||||
|
|
||||||
|
" Go to the preview window
|
||||||
|
wincmd P
|
||||||
|
call assert_equal(1, &previewwindow)
|
||||||
|
call assert_equal('preview', win_gettype())
|
||||||
|
|
||||||
|
" Close preview window
|
||||||
|
wincmd z
|
||||||
|
call assert_equal(1, winnr('$'))
|
||||||
|
call assert_equal(0, &previewwindow)
|
||||||
|
|
||||||
|
call assert_fails('wincmd P', 'E441:')
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Test_window_preview_from_help()
|
||||||
|
filetype on
|
||||||
|
call writefile(['/* some C code */'], 'Xpreview.c')
|
||||||
|
help
|
||||||
|
pedit Xpreview.c
|
||||||
|
wincmd P
|
||||||
|
call assert_equal(1, &previewwindow)
|
||||||
|
call assert_equal('c', &filetype)
|
||||||
|
wincmd z
|
||||||
|
|
||||||
|
filetype off
|
||||||
|
close
|
||||||
|
call delete('Xpreview.c')
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Test_multiple_preview_windows()
|
||||||
|
new
|
||||||
|
set previewwindow
|
||||||
|
new
|
||||||
|
call assert_fails('set previewwindow', 'E590:')
|
||||||
|
%bw!
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
@@ -172,39 +172,6 @@ func Test_window_split_edit_bufnr()
|
|||||||
%bw!
|
%bw!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_window_preview()
|
|
||||||
" Open a preview window
|
|
||||||
pedit Xa
|
|
||||||
call assert_equal(2, winnr('$'))
|
|
||||||
call assert_equal(0, &previewwindow)
|
|
||||||
|
|
||||||
" Go to the preview window
|
|
||||||
wincmd P
|
|
||||||
call assert_equal(1, &previewwindow)
|
|
||||||
|
|
||||||
" Close preview window
|
|
||||||
wincmd z
|
|
||||||
call assert_equal(1, winnr('$'))
|
|
||||||
call assert_equal(0, &previewwindow)
|
|
||||||
|
|
||||||
call assert_fails('wincmd P', 'E441:')
|
|
||||||
endfunc
|
|
||||||
|
|
||||||
func Test_window_preview_from_help()
|
|
||||||
filetype on
|
|
||||||
call writefile(['/* some C code */'], 'Xpreview.c')
|
|
||||||
help
|
|
||||||
pedit Xpreview.c
|
|
||||||
wincmd P
|
|
||||||
call assert_equal(1, &previewwindow)
|
|
||||||
call assert_equal('c', &filetype)
|
|
||||||
wincmd z
|
|
||||||
|
|
||||||
filetype off
|
|
||||||
close
|
|
||||||
call delete('Xpreview.c')
|
|
||||||
endfunc
|
|
||||||
|
|
||||||
func Test_window_exchange()
|
func Test_window_exchange()
|
||||||
e Xa
|
e Xa
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user