diff options
author | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2020-11-25 02:27:10 -0500 |
---|---|---|
committer | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2020-11-25 02:45:00 -0500 |
commit | 9b2efe6b7d40d6ef317751768a65c74e4e2e8152 (patch) | |
tree | 90005568ab027108eed21fa4ccfcbc8135cc024d /src | |
parent | ede747c2cc84382e8746df8992ef0e403647ffde (diff) | |
download | rneovim-9b2efe6b7d40d6ef317751768a65c74e4e2e8152.tar.gz rneovim-9b2efe6b7d40d6ef317751768a65c74e4e2e8152.tar.bz2 rneovim-9b2efe6b7d40d6ef317751768a65c74e4e2e8152.zip |
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)
https://github.com/vim/vim/commit/0fe937fd8616fcd24b1b1ef2ab9f1657615dd22c
Cherry-pick test_preview.vim,test_window_cmd.vim changes
from patch v8.2.0522.
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/eval/funcs.c | 6 | ||||
-rw-r--r-- | src/nvim/testdir/test_autocmd.vim | 22 | ||||
-rw-r--r-- | src/nvim/testdir/test_preview.vim | 44 | ||||
-rw-r--r-- | src/nvim/testdir/test_window_cmd.vim | 33 |
4 files changed, 71 insertions, 34 deletions
diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c index 090133c868..d07efc297e 100644 --- a/src/nvim/eval/funcs.c +++ b/src/nvim/eval/funcs.c @@ -11006,7 +11006,11 @@ static void f_win_gettype(typval_T *argvars, typval_T *rettv, FunPtr fptr) 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"); } else if (wp == curwin && cmdwin_type != 0) { rettv->vval.v_string = vim_strsave((char_u *)"command"); diff --git a/src/nvim/testdir/test_autocmd.vim b/src/nvim/testdir/test_autocmd.vim index 22f03e1076..a2695ec354 100644 --- a/src/nvim/testdir/test_autocmd.vim +++ b/src/nvim/testdir/test_autocmd.vim @@ -1934,4 +1934,26 @@ func Test_autocmd_sigusr1() unlet g:sigusr1_passed 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 diff --git a/src/nvim/testdir/test_preview.vim b/src/nvim/testdir/test_preview.vim index 91923fb1e9..6c4ae414d3 100644 --- a/src/nvim/testdir/test_preview.vim +++ b/src/nvim/testdir/test_preview.vim @@ -11,3 +11,47 @@ func Test_Psearch() call assert_equal(wincount, winnr('$')) bwipe 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 diff --git a/src/nvim/testdir/test_window_cmd.vim b/src/nvim/testdir/test_window_cmd.vim index 500e3ff088..c630e678fd 100644 --- a/src/nvim/testdir/test_window_cmd.vim +++ b/src/nvim/testdir/test_window_cmd.vim @@ -172,39 +172,6 @@ func Test_window_split_edit_bufnr() %bw! 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() e Xa |