aboutsummaryrefslogtreecommitdiff
path: root/test/old/testdir/test_preview.vim
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-12-17 11:34:30 +0800
committerGitHub <noreply@github.com>2024-12-17 03:34:30 +0000
commitb03e790cddd19b57fa91f4fbfcc30c28f3c173bf (patch)
tree9a6841d79d079ab0a052c0d72aa3bb9138033a1c /test/old/testdir/test_preview.vim
parent15153c4cd5319652bcdcd608fe5d4f0fa1eb9419 (diff)
downloadrneovim-b03e790cddd19b57fa91f4fbfcc30c28f3c173bf.tar.gz
rneovim-b03e790cddd19b57fa91f4fbfcc30c28f3c173bf.tar.bz2
rneovim-b03e790cddd19b57fa91f4fbfcc30c28f3c173bf.zip
vim-patch:9.1.0934: hard to view an existing buffer in the preview window (#31605)
Problem: hard to view an existing buffer in the preview window Solution: add the :pbuffer command (Yinzuo Jiang) Similar as `:pedit` and `:buffer` command. `:pbuffer` edits buffer [N] from the buffer list in the preview window. `:pbuffer` can also open special buffer, for example terminal buffer. closes: vim/vim#16222 https://github.com/vim/vim/commit/a2a2fe841ed2efdbb1f8055f752a3a4d0988ae9d Cherry-pick Test_popup_and_previewwindow_dump() changes from patch 9.0.0625. Cherry-pick Run_noroom_for_newwindow_test() changes from patches 8.2.0432 and 9.0.0363. Co-authored-by: Yinzuo Jiang <jiangyinzuo@foxmail.com>
Diffstat (limited to 'test/old/testdir/test_preview.vim')
-rw-r--r--test/old/testdir/test_preview.vim47
1 files changed, 40 insertions, 7 deletions
diff --git a/test/old/testdir/test_preview.vim b/test/old/testdir/test_preview.vim
index b7b908e761..d24b09b7d2 100644
--- a/test/old/testdir/test_preview.vim
+++ b/test/old/testdir/test_preview.vim
@@ -15,6 +15,20 @@ func Test_Psearch()
bwipe
endfunc
+func s:goto_preview_and_close()
+ " 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()
CheckFeature quickfix
@@ -23,17 +37,36 @@ func Test_window_preview()
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())
+ call s:goto_preview_and_close()
+endfunc
- " Close preview window
- wincmd z
+func Test_window_preview_from_pbuffer()
+ CheckFeature quickfix
+
+ call writefile(['/* some C code */'], 'Xpreview.c', 'D')
+ edit Xpreview.c
+ const buf_num = bufnr('%')
+ enew
call assert_equal(1, winnr('$'))
+ exe 'pbuffer ' . buf_num
+ call assert_equal(2, winnr('$'))
call assert_equal(0, &previewwindow)
- call assert_fails('wincmd P', 'E441:')
+ call s:goto_preview_and_close()
+endfunc
+
+func Test_window_preview_terminal()
+ CheckFeature quickfix
+ " CheckFeature terminal
+
+ term " ++curwin
+ const buf_num = bufnr('$')
+ call assert_equal(1, winnr('$'))
+ exe 'pbuffer' . buf_num
+ call assert_equal(2, winnr('$'))
+ call assert_equal(0, &previewwindow)
+
+ call s:goto_preview_and_close()
endfunc
func Test_window_preview_from_help()