From b03e790cddd19b57fa91f4fbfcc30c28f3c173bf Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Tue, 17 Dec 2024 11:34:30 +0800 Subject: 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 --- test/old/testdir/test_preview.vim | 47 +++++++++++++++++++++++++++++++++------ 1 file changed, 40 insertions(+), 7 deletions(-) (limited to 'test/old/testdir/test_preview.vim') 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() -- cgit From 738320188ffc389f1dc04f67a06c280f2d4ae41d Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Wed, 18 Dec 2024 10:21:52 +0800 Subject: test(old): fix incorrect comment in test_preview.vim (#31619) --- test/old/testdir/test_preview.vim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'test/old/testdir/test_preview.vim') diff --git a/test/old/testdir/test_preview.vim b/test/old/testdir/test_preview.vim index d24b09b7d2..424d93f54d 100644 --- a/test/old/testdir/test_preview.vim +++ b/test/old/testdir/test_preview.vim @@ -59,7 +59,8 @@ func Test_window_preview_terminal() CheckFeature quickfix " CheckFeature terminal - term " ++curwin + " term ++curwin + term const buf_num = bufnr('$') call assert_equal(1, winnr('$')) exe 'pbuffer' . buf_num -- cgit From 889f9a0c5d1f3fe522af0d2b43a82317b0589b94 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 20 Dec 2024 08:04:46 +0800 Subject: vim-patch:9.1.0948: Missing cmdline completion for :pbuffer (#31645) Problem: Missing cmdline completion for :pbuffer. Solution: Add cmdline completion for :pbuffer like :buffer. (zeertzjq) fixes: vim/vim#16250 closes: vim/vim#16251 https://github.com/vim/vim/commit/3baf19a2b144b215c5b537c3c1b3b80a79b0fe99 --- test/old/testdir/test_preview.vim | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'test/old/testdir/test_preview.vim') diff --git a/test/old/testdir/test_preview.vim b/test/old/testdir/test_preview.vim index 424d93f54d..422c50ac77 100644 --- a/test/old/testdir/test_preview.vim +++ b/test/old/testdir/test_preview.vim @@ -47,12 +47,23 @@ func Test_window_preview_from_pbuffer() edit Xpreview.c const buf_num = bufnr('%') enew + + call feedkeys(":pbuffer Xpre\\\"\", 'xt') + call assert_equal("\"pbuffer Xpreview.c", @:) + 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() + + call assert_equal(1, winnr('$')) + pbuffer Xpreview.c + call assert_equal(2, winnr('$')) + call assert_equal(0, &previewwindow) + + call s:goto_preview_and_close() endfunc func Test_window_preview_terminal() -- cgit