forked from aniani/vim
patch 8.1.0141: :cexpr no longer jumps to the first error
Problem: :cexpr no longer jumps to the first error.
Solution: Use the quickfix list identifier. (Yegappan Lakshmanan,
closes #3092)
This commit is contained in:
@@ -3363,13 +3363,124 @@ func Test_lbuffer_with_bwipe()
|
||||
augroup END
|
||||
endfunc
|
||||
|
||||
func Test_setloclist_in_aucmd()
|
||||
" Test for an autocmd freeing the quickfix/location list when cexpr/lexpr is
|
||||
" running
|
||||
func Xexpr_acmd_freelist(cchar)
|
||||
call s:setup_commands(a:cchar)
|
||||
|
||||
" This was using freed memory.
|
||||
augroup nasty
|
||||
au * * call setloclist(0, [], 'f')
|
||||
au * * call g:Xsetlist([], 'f')
|
||||
augroup END
|
||||
lexpr "x"
|
||||
Xexpr "x"
|
||||
augroup nasty
|
||||
au!
|
||||
augroup END
|
||||
endfunc
|
||||
|
||||
func Test_cexpr_acmd_freelist()
|
||||
call Xexpr_acmd_freelist('c')
|
||||
call Xexpr_acmd_freelist('l')
|
||||
endfunc
|
||||
|
||||
" Test for commands that create a new quickfix/location list and jump to the
|
||||
" first error automatically.
|
||||
func Xjumpto_first_error_test(cchar)
|
||||
call s:setup_commands(a:cchar)
|
||||
|
||||
call s:create_test_file('Xtestfile1')
|
||||
call s:create_test_file('Xtestfile2')
|
||||
let l = ['Xtestfile1:2:Line2', 'Xtestfile2:4:Line4']
|
||||
|
||||
" Test for cexpr/lexpr
|
||||
enew
|
||||
Xexpr l
|
||||
call assert_equal('Xtestfile1', bufname(''))
|
||||
call assert_equal(2, line('.'))
|
||||
|
||||
" Test for cfile/lfile
|
||||
enew
|
||||
call writefile(l, 'Xerr')
|
||||
Xfile Xerr
|
||||
call assert_equal('Xtestfile1', bufname(''))
|
||||
call assert_equal(2, line('.'))
|
||||
|
||||
" Test for cbuffer/lbuffer
|
||||
edit Xerr
|
||||
Xbuffer
|
||||
call assert_equal('Xtestfile1', bufname(''))
|
||||
call assert_equal(2, line('.'))
|
||||
|
||||
call delete('Xerr')
|
||||
call delete('Xtestfile1')
|
||||
call delete('Xtestfile2')
|
||||
endfunc
|
||||
|
||||
func Test_jumpto_first_error()
|
||||
call Xjumpto_first_error_test('c')
|
||||
call Xjumpto_first_error_test('l')
|
||||
endfunc
|
||||
|
||||
" Test for a quickfix autocmd changing the quickfix/location list before
|
||||
" jumping to the first error in the new list.
|
||||
func Xautocmd_changelist(cchar)
|
||||
call s:setup_commands(a:cchar)
|
||||
|
||||
" Test for cfile/lfile
|
||||
call s:create_test_file('Xtestfile1')
|
||||
call s:create_test_file('Xtestfile2')
|
||||
Xexpr 'Xtestfile1:2:Line2'
|
||||
autocmd QuickFixCmdPost * Xolder
|
||||
call writefile(['Xtestfile2:4:Line4'], 'Xerr')
|
||||
Xfile Xerr
|
||||
call assert_equal('Xtestfile2', bufname(''))
|
||||
call assert_equal(4, line('.'))
|
||||
autocmd! QuickFixCmdPost
|
||||
|
||||
" Test for cbuffer/lbuffer
|
||||
call g:Xsetlist([], 'f')
|
||||
Xexpr 'Xtestfile1:2:Line2'
|
||||
autocmd QuickFixCmdPost * Xolder
|
||||
call writefile(['Xtestfile2:4:Line4'], 'Xerr')
|
||||
edit Xerr
|
||||
Xbuffer
|
||||
call assert_equal('Xtestfile2', bufname(''))
|
||||
call assert_equal(4, line('.'))
|
||||
autocmd! QuickFixCmdPost
|
||||
|
||||
" Test for cexpr/lexpr
|
||||
call g:Xsetlist([], 'f')
|
||||
Xexpr 'Xtestfile1:2:Line2'
|
||||
autocmd QuickFixCmdPost * Xolder
|
||||
Xexpr 'Xtestfile2:4:Line4'
|
||||
call assert_equal('Xtestfile2', bufname(''))
|
||||
call assert_equal(4, line('.'))
|
||||
autocmd! QuickFixCmdPost
|
||||
|
||||
" Test for grep/lgrep
|
||||
call g:Xsetlist([], 'f')
|
||||
Xexpr 'Xtestfile1:2:Line2'
|
||||
autocmd QuickFixCmdPost * Xolder
|
||||
silent Xgrep Line5 Xtestfile2
|
||||
call assert_equal('Xtestfile2', bufname(''))
|
||||
call assert_equal(5, line('.'))
|
||||
autocmd! QuickFixCmdPost
|
||||
|
||||
" Test for vimgrep/lvimgrep
|
||||
call g:Xsetlist([], 'f')
|
||||
Xexpr 'Xtestfile1:2:Line2'
|
||||
autocmd QuickFixCmdPost * Xolder
|
||||
silent Xvimgrep Line5 Xtestfile2
|
||||
call assert_equal('Xtestfile2', bufname(''))
|
||||
call assert_equal(5, line('.'))
|
||||
autocmd! QuickFixCmdPost
|
||||
|
||||
call delete('Xerr')
|
||||
call delete('Xtestfile1')
|
||||
call delete('Xtestfile2')
|
||||
endfunc
|
||||
|
||||
func Test_autocmd_changelist()
|
||||
call Xautocmd_changelist('c')
|
||||
call Xautocmd_changelist('l')
|
||||
endfunc
|
||||
|
||||
Reference in New Issue
Block a user