vim-patch:8.1.0877: new buffer used every time the quickfix window is opened

Problem:    New buffer used every time the quickfix window is opened.
Solution:   Reuse the buffer. (Yegappan Lakshmanan, closes vim/vim#3902)
ee8188fc74
This commit is contained in:
Jan Edmund Lazo
2020-10-10 13:11:34 -04:00
parent e9004e2af0
commit e82b8ddef1
3 changed files with 99 additions and 35 deletions

View File

@@ -4028,6 +4028,49 @@ func Test_viscol()
call delete('Xfile1')
endfunc
" Test for the quickfix window buffer
func Xqfbuf_test(cchar)
call s:setup_commands(a:cchar)
" Quickfix buffer should be reused across closing and opening a quickfix
" window
Xexpr "F1:10:Line10"
Xopen
let qfbnum = bufnr('')
Xclose
" Even after the quickfix window is closed, the buffer should be loaded
call assert_true(bufloaded(qfbnum))
Xopen
" Buffer should be reused when opening the window again
call assert_equal(qfbnum, bufnr(''))
Xclose
if a:cchar == 'l'
%bwipe
" For a location list, when both the file window and the location list
" window for the list are closed, then the buffer should be freed.
new | only
lexpr "F1:10:Line10"
let wid = win_getid()
lopen
let qfbnum = bufnr('')
call assert_match(qfbnum . ' %a- "\[Location List]"', execute('ls'))
close
" When the location list window is closed, the buffer name should not
" change to 'Quickfix List'
call assert_match(qfbnum . ' h- "\[Location List]"', execute('ls'))
call assert_true(bufloaded(qfbnum))
new | only
call assert_false(bufloaded(qfbnum))
endif
endfunc
func Test_qfbuf()
call Xqfbuf_test('c')
call Xqfbuf_test('l')
endfunc
" Test to make sure that an empty quickfix buffer is not reused for loading
" a normal buffer.
func Test_empty_qfbuf()