diff src/testdir/test_quickfix.vim @ 15024:3a3c9b638187 v8.1.0523

patch 8.1.0523: opening window from quickfix leaves empty buffer behind commit https://github.com/vim/vim/commit/b244373becbec124bee20dbbfd05365586cda8cd Author: Bram Moolenaar <Bram@vim.org> Date: Sun Nov 11 22:50:27 2018 +0100 patch 8.1.0523: opening window from quickfix leaves empty buffer behind Problem: Opening window from quickfix leaves empty buffer behind. Solution: Add qf_jump_newwin(). (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/2574)
author Bram Moolenaar <Bram@vim.org>
date Sun, 11 Nov 2018 23:00:05 +0100
parents 676db1b7fc35
children a413374825dd
line wrap: on
line diff
--- a/src/testdir/test_quickfix.vim
+++ b/src/testdir/test_quickfix.vim
@@ -3718,3 +3718,49 @@ func Test_curswant()
   call assert_equal(getcurpos()[4], virtcol('.'))
   cclose | helpclose
 endfunc
+
+" Test for opening a file from the quickfix window using CTRL-W <Enter>
+" doesn't leave an empty buffer around.
+func Test_splitview()
+  call s:create_test_file('Xtestfile1')
+  call s:create_test_file('Xtestfile2')
+  new | only
+  let last_bufnr = bufnr('Test_sv_1', 1)
+  let l = ['Xtestfile1:2:Line2', 'Xtestfile2:4:Line4']
+  cgetexpr l
+  copen
+  let numbufs = len(getbufinfo())
+  exe "normal \<C-W>\<CR>"
+  copen
+  exe "normal j\<C-W>\<CR>"
+  " Make sure new empty buffers are not created
+  call assert_equal(numbufs, len(getbufinfo()))
+  " Creating a new buffer should use the next available buffer number
+  call assert_equal(last_bufnr + 4, bufnr("Test_sv_2", 1))
+  bwipe Test_sv_1
+  bwipe Test_sv_2
+  new | only
+
+  " When split opening files from location list window, make sure that two
+  " windows doesn't refer to the same location list
+  lgetexpr l
+  let locid = getloclist(0, {'id' : 0}).id
+  lopen
+  exe "normal \<C-W>\<CR>"
+  call assert_notequal(locid, getloclist(0, {'id' : 0}).id)
+  call assert_equal(0, getloclist(0, {'winid' : 0}).winid)
+  new | only
+
+  " When split opening files from a helpgrep location list window, a new help
+  " window should be opend with a copy of the location list.
+  lhelpgrep window
+  let locid = getloclist(0, {'id' : 0}).id
+  lwindow
+  exe "normal j\<C-W>\<CR>"
+  call assert_notequal(locid, getloclist(0, {'id' : 0}).id)
+  call assert_equal(0, getloclist(0, {'winid' : 0}).winid)
+  new | only
+
+  call delete('Xtestfile1')
+  call delete('Xtestfile2')
+endfunc