Mercurial > vim
diff src/testdir/test_quickfix.vim @ 14250:ca6ccee4823f v8.1.0141
patch 8.1.0141: :cexpr no longer jumps to the first error
commit https://github.com/vim/vim/commit/531b9a3a638cb1147db4f096bfbcb14d2ae32b04
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Jul 3 16:54:23 2018 +0200
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)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Tue, 03 Jul 2018 17:00:06 +0200 |
parents | 678e326bf7eb |
children | 71bb93bf9a44 |
line wrap: on
line diff
--- a/src/testdir/test_quickfix.vim +++ b/src/testdir/test_quickfix.vim @@ -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