patch 9.1.0934: hard to view an existing buffer in the preview window
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: #16222
Signed-off-by: Yinzuo Jiang <jiangyinzuo@foxmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
diff --git a/src/testdir/test_preview.vim b/src/testdir/test_preview.vim
index 3d13d99..0df1a90 100644
--- a/src/testdir/test_preview.vim
+++ b/src/testdir/test_preview.vim
@@ -15,14 +15,7 @@
bwipe
endfunc
-func Test_window_preview()
- CheckFeature quickfix
-
- " Open a preview window
- pedit Xa
- call assert_equal(2, winnr('$'))
- call assert_equal(0, &previewwindow)
-
+func s:goto_preview_and_close()
" Go to the preview window
wincmd P
call assert_equal(1, &previewwindow)
@@ -36,6 +29,46 @@
call assert_fails('wincmd P', 'E441:')
endfunc
+func Test_window_preview()
+ CheckFeature quickfix
+
+ " Open a preview window
+ pedit Xa
+ call assert_equal(2, winnr('$'))
+ call assert_equal(0, &previewwindow)
+
+ call s:goto_preview_and_close()
+endfunc
+
+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 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()
CheckFeature quickfix