forked from aniani/vim
patch 8.1.0892: failure when closing a window when location list is in use
Problem: Failure when closing a window when location list is in use.
Solution: Handle the situation gracefully. Make sure memory for 'switchbuf'
is not freed at the wrong time. (Yegappan Lakshmanan,
closes #3928)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
" Test for the quickfix commands.
|
||||
" Test for the quickfix feature.
|
||||
|
||||
if !has('quickfix')
|
||||
finish
|
||||
@@ -1419,7 +1419,7 @@ func XquickfixSetListWithAct(cchar)
|
||||
\ {'filename': 'fnameD', 'text': 'D'},
|
||||
\ {'filename': 'fnameE', 'text': 'E'}]
|
||||
|
||||
" {action} is unspecified. Same as specifing ' '.
|
||||
" {action} is unspecified. Same as specifying ' '.
|
||||
new | only
|
||||
silent! Xnewer 99
|
||||
call g:Xsetlist(list1)
|
||||
@@ -2348,7 +2348,7 @@ func Test_cwindow_jump()
|
||||
" Open a new window and create a location list
|
||||
" Open the location list window and close the other window
|
||||
" Jump to an entry.
|
||||
" Should create a new window and jump to the entry. The scrtach buffer
|
||||
" Should create a new window and jump to the entry. The scratch buffer
|
||||
" should not be used.
|
||||
enew | only
|
||||
set buftype=nofile
|
||||
@@ -3831,7 +3831,7 @@ func Test_splitview()
|
||||
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.
|
||||
" window should be opened with a copy of the location list.
|
||||
lhelpgrep window
|
||||
let locid = getloclist(0, {'id' : 0}).id
|
||||
lwindow
|
||||
@@ -3933,8 +3933,30 @@ func Xqfbuf_test(cchar)
|
||||
call assert_match(qfbnum . ' h- "\[Location List]"', execute('ls'))
|
||||
call assert_true(bufloaded(qfbnum))
|
||||
|
||||
" When the location list is cleared for the window, the buffer should be
|
||||
" removed
|
||||
call setloclist(0, [], 'f')
|
||||
call assert_false(bufexists(qfbnum))
|
||||
|
||||
" When the location list is freed with the location list window open, the
|
||||
" location list buffer should not be lost. It should be reused when the
|
||||
" location list is again populated.
|
||||
lexpr "F1:10:Line10"
|
||||
lopen
|
||||
let wid = win_getid()
|
||||
let qfbnum = bufnr('')
|
||||
wincmd p
|
||||
call setloclist(0, [], 'f')
|
||||
lexpr "F1:10:Line10"
|
||||
lopen
|
||||
call assert_equal(wid, win_getid())
|
||||
call assert_equal(qfbnum, bufnr(''))
|
||||
lclose
|
||||
|
||||
" When the window with the location list is closed, the buffer should be
|
||||
" removed
|
||||
new | only
|
||||
call assert_false(bufloaded(qfbnum))
|
||||
call assert_false(bufexists(qfbnum))
|
||||
endif
|
||||
endfunc
|
||||
|
||||
@@ -3942,3 +3964,29 @@ func Test_qfbuf()
|
||||
call Xqfbuf_test('c')
|
||||
call Xqfbuf_test('l')
|
||||
endfunc
|
||||
|
||||
" If there is an autocmd to use only one window, then opening the location
|
||||
" list window used to crash Vim.
|
||||
func Test_winonly_autocmd()
|
||||
call s:create_test_file('Xtest1')
|
||||
" Autocmd to show only one Vim window at a time
|
||||
autocmd WinEnter * only
|
||||
new
|
||||
" Load the location list
|
||||
lexpr "Xtest1:5:Line5\nXtest1:10:Line10\nXtest1:15:Line15"
|
||||
let loclistid = getloclist(0, {'id' : 0}).id
|
||||
" Open the location list window. Only this window will be shown and the file
|
||||
" window is closed.
|
||||
lopen
|
||||
call assert_equal(loclistid, getloclist(0, {'id' : 0}).id)
|
||||
" Jump to an entry in the location list and make sure that the cursor is
|
||||
" positioned correctly.
|
||||
ll 3
|
||||
call assert_equal(loclistid, getloclist(0, {'id' : 0}).id)
|
||||
call assert_equal('Xtest1', bufname(''))
|
||||
call assert_equal(15, line('.'))
|
||||
" Cleanup
|
||||
autocmd! WinEnter
|
||||
new | only
|
||||
call delete('Xtest1')
|
||||
endfunc
|
||||
|
||||
Reference in New Issue
Block a user