From 773c488140415ce9f19ddee5add676d3699104d3 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Wed, 5 Jun 2019 22:52:38 -0400 Subject: vim-patch:8.0.1384: not enough quickfix help; confusing winid Problem: Not enough quickfix help; confusing winid. Solution: Add more examples in the help. When the quickfix window is not present, return zero for getqflist() with 'winid'. Add more tests for jumping to quickfix list entries. (Yegappan Lakshmanan, closes vim/vim#2427) https://github.com/vim/vim/commit/74240d3febd1e3bc7cf086c647c9348b20716c33 --- src/nvim/testdir/test_quickfix.vim | 149 +++++++++++++++++++++++++++++++++++-- 1 file changed, 141 insertions(+), 8 deletions(-) (limited to 'src/nvim/testdir/test_quickfix.vim') diff --git a/src/nvim/testdir/test_quickfix.vim b/src/nvim/testdir/test_quickfix.vim index c6d083dfcc..b009df26b9 100644 --- a/src/nvim/testdir/test_quickfix.vim +++ b/src/nvim/testdir/test_quickfix.vim @@ -28,7 +28,7 @@ func s:setup_commands(cchar) command! -count -nargs=* -bang Xprev cprev command! -nargs=* -bang Xfirst cfirst command! -nargs=* -bang Xlast clast - command! -nargs=* -bang Xnfile cnfile + command! -nargs=* -bang -range Xnfile cnfile command! -nargs=* -bang Xpfile cpfile command! -nargs=* Xexpr cexpr command! -range -nargs=* Xvimgrep vimgrep @@ -36,6 +36,7 @@ func s:setup_commands(cchar) command! -nargs=* Xgrep grep command! -nargs=* Xgrepadd grepadd command! -nargs=* Xhelpgrep helpgrep + command! -nargs=0 -count Xcc cc let g:Xgetlist = function('getqflist') let g:Xsetlist = function('setqflist') call setqflist([], 'f') @@ -60,7 +61,7 @@ func s:setup_commands(cchar) command! -count -nargs=* -bang Xprev lprev command! -nargs=* -bang Xfirst lfirst command! -nargs=* -bang Xlast llast - command! -nargs=* -bang Xnfile lnfile + command! -nargs=* -bang -range Xnfile lnfile command! -nargs=* -bang Xpfile lpfile command! -nargs=* Xexpr lexpr command! -range -nargs=* Xvimgrep lvimgrep @@ -68,6 +69,7 @@ func s:setup_commands(cchar) command! -nargs=* Xgrep lgrep command! -nargs=* Xgrepadd lgrepadd command! -nargs=* Xhelpgrep lhelpgrep + command! -nargs=0 -count Xcc ll let g:Xgetlist = function('getloclist', [0]) let g:Xsetlist = function('setloclist', [0]) call setloclist(0, [], 'f') @@ -395,12 +397,18 @@ endfunc func Xtest_browse(cchar) call s:setup_commands(a:cchar) + call g:Xsetlist([], 'f') " Jumping to first or next location list entry without any error should " result in failure - if a:cchar == 'l' - call assert_fails('lfirst', 'E776:') - call assert_fails('lnext', 'E776:') + if a:cchar == 'c' + let err = 'E42:' + else + let err = 'E776:' endif + call assert_fails('Xnext', err) + call assert_fails('Xprev', err) + call assert_fails('Xnfile', err) + call assert_fails('Xpfile', err) call s:create_test_file('Xqftestfile1') call s:create_test_file('Xqftestfile2') @@ -421,6 +429,12 @@ func Xtest_browse(cchar) Xpfile call assert_equal('Xqftestfile1', bufname('%')) call assert_equal(6, line('.')) + 5Xcc + call assert_equal(5, g:Xgetlist({'idx':0}).idx) + 2Xcc + call assert_equal(2, g:Xgetlist({'idx':0}).idx) + 10Xcc + call assert_equal(6, g:Xgetlist({'idx':0}).idx) Xlast Xprev call assert_equal('Xqftestfile2', bufname('%')) @@ -438,6 +452,23 @@ func Xtest_browse(cchar) call assert_equal('Xqftestfile1', bufname('%')) call assert_equal(5, line('.')) + " Jumping to an error from the error window using cc command + Xgetexpr ['Xqftestfile1:5:Line5', + \ 'Xqftestfile1:6:Line6', + \ 'Xqftestfile2:10:Line10', + \ 'Xqftestfile2:11:Line11'] + Xopen + 10Xcc + call assert_equal(11, line('.')) + call assert_equal('Xqftestfile2', bufname('%')) + + " Jumping to an error from the error window (when only the error window is + " present) + Xopen | only + Xlast 1 + call assert_equal(5, line('.')) + call assert_equal('Xqftestfile1', bufname('%')) + Xexpr "" call assert_fails('Xnext', 'E42:') @@ -1512,13 +1543,18 @@ func Test_switchbuf() set switchbuf=usetab tabedit Xqftestfile1 tabedit Xqftestfile2 + tabedit Xqftestfile3 tabfirst cfirst | cnext call assert_equal(2, tabpagenr()) 2cnext call assert_equal(3, tabpagenr()) - 2cnext - call assert_equal(3, tabpagenr()) + 6cnext + call assert_equal(4, tabpagenr()) + 2cpfile + call assert_equal(2, tabpagenr()) + 2cnfile + call assert_equal(4, tabpagenr()) tabfirst | tabonly | enew set switchbuf=split @@ -2338,7 +2374,7 @@ func XfreeTests(cchar) Xclose endfunc -" Tests for the quickifx free functionality +" Tests for the quickfix free functionality func Test_qf_free() call XfreeTests('c') call XfreeTests('l') @@ -3165,3 +3201,100 @@ func Test_lvimgrep_crash() augroup END enew | only endfunc + +func Xqfjump_tests(cchar) + call s:setup_commands(a:cchar) + + call writefile(["Line1\tFoo", "Line2"], 'F1') + call writefile(["Line1\tBar", "Line2"], 'F2') + call writefile(["Line1\tBaz", "Line2"], 'F3') + + call g:Xsetlist([], 'f') + + " Tests for + " Jumping to a line using a pattern + " Jumping to a column greater than the last column in a line + " Jumping to a line greater than the last line in the file + let l = [] + for i in range(1, 7) + call add(l, {}) + endfor + let l[0].filename='F1' + let l[0].pattern='Line1' + let l[1].filename='F2' + let l[1].pattern='Line1' + let l[2].filename='F3' + let l[2].pattern='Line1' + let l[3].filename='F3' + let l[3].lnum=1 + let l[3].col=9 + let l[3].vcol=1 + let l[4].filename='F3' + let l[4].lnum=99 + let l[5].filename='F3' + let l[5].lnum=1 + let l[5].col=99 + let l[5].vcol=1 + let l[6].filename='F3' + let l[6].pattern='abcxyz' + + call g:Xsetlist([], ' ', {'items' : l}) + Xopen | only + 2Xnext + call assert_equal(3, g:Xgetlist({'idx' : 0}).idx) + call assert_equal('F3', bufname('%')) + Xnext + call assert_equal(7, col('.')) + Xnext + call assert_equal(2, line('.')) + Xnext + call assert_equal(9, col('.')) + 2 + Xnext + call assert_equal(2, line('.')) + + if a:cchar == 'l' + " When jumping to a location list entry in the location list window and + " no usable windows are available, then a new window should be opened. + enew! | new | only + call g:Xsetlist([], 'f') + setlocal buftype=nofile + new + call g:Xsetlist([], ' ', {'lines' : ['F1:1:1:Line1', 'F1:2:2:Line2', 'F2:1:1:Line1', 'F2:2:2:Line2', 'F3:1:1:Line1', 'F3:2:2:Line2']}) + Xopen + let winid = win_getid() + wincmd p + close + call win_gotoid(winid) + Xnext + call assert_equal(3, winnr('$')) + call assert_equal(1, winnr()) + call assert_equal(2, line('.')) + + " When jumping to an entry in the location list window and the window + " associated with the location list is not present and a window containing + " the file is already present, then that window should be used. + close + belowright new + call g:Xsetlist([], 'f') + edit F3 + call win_gotoid(winid) + Xlast + call assert_equal(3, winnr()) + call assert_equal(6, g:Xgetlist({'size' : 1}).size) + call assert_equal(winid, g:Xgetlist({'winid' : 1}).winid) + endif + + " Cleanup + enew! + new | only + + call delete('F1') + call delete('F2') + call delete('F3') +endfunc + +func Test_qfjump() + call Xqfjump_tests('c') + call Xqfjump_tests('l') +endfunc -- cgit From 427140048b7cc8b48bdd53683247513acefb77ba Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Wed, 5 Jun 2019 23:12:20 -0400 Subject: vim-patch:8.0.1412: using free memory using setloclist() Problem: Using free memory using setloclist(). (Dominique Pelle) Solution: Mark location list context as still in use when needed. (Yegappan Lakshmanan, closes vim/vim#2462) https://github.com/vim/vim/commit/12237448499aaeb8c4f2be7a1deda60c0f160627 --- src/nvim/testdir/test_quickfix.vim | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/nvim/testdir/test_quickfix.vim') diff --git a/src/nvim/testdir/test_quickfix.vim b/src/nvim/testdir/test_quickfix.vim index b009df26b9..db84f6d4a1 100644 --- a/src/nvim/testdir/test_quickfix.vim +++ b/src/nvim/testdir/test_quickfix.vim @@ -3298,3 +3298,17 @@ func Test_qfjump() call Xqfjump_tests('c') call Xqfjump_tests('l') endfunc + +" The following test used to crash Vim. +" Open the location list window and close the regular window associated with +" the location list. When the garbage collection runs now, it incorrectly +" marks the location list context as not in use and frees the context. +func Test_ll_window_ctx() + call setloclist(0, [], 'f') + call setloclist(0, [], 'a', {'context' : []}) + lopen | only + call test_garbagecollect_now() + echo getloclist(0, {'context' : 1}).context + enew | only +endfunc + -- cgit From 0234d579a72a81349901c7ec4f7bca6b4bc6f132 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Wed, 5 Jun 2019 23:18:11 -0400 Subject: vim-patch:8.0.1414: accessing freed memory in :lfile. Problem: Accessing freed memory in :lfile. Solution: Get the current window after executing autocommands. (Yegappan Lakshmanan, closes vim/vim#2473) https://github.com/vim/vim/commit/14a4deb064610c30a50f00d524dde9b3292aad59 --- src/nvim/testdir/test_quickfix.vim | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/nvim/testdir/test_quickfix.vim') diff --git a/src/nvim/testdir/test_quickfix.vim b/src/nvim/testdir/test_quickfix.vim index db84f6d4a1..9fbd3d25bd 100644 --- a/src/nvim/testdir/test_quickfix.vim +++ b/src/nvim/testdir/test_quickfix.vim @@ -3312,3 +3312,10 @@ func Test_ll_window_ctx() enew | only endfunc +" The following test used to crash vim +func Test_lfile_crash() + sp Xtest + au QuickFixCmdPre * bw + call assert_fails('lfile', 'E40') + au! QuickFixCmdPre +endfunc -- cgit From fb2b0fa5babe4d3f68012c12345ed32e82584c3b Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Thu, 6 Jun 2019 04:52:06 -0400 Subject: vim-patch:8.0.1669: :vimgrep may add entries to the wrong quickfix list Problem: :vimgrep may add entries to the wrong quickfix list. Solution: Use the list identifier. (Yegappan Lakshmanan) https://github.com/vim/vim/commit/e1bb879f49665bb828197135b80aaf72cc190073 --- src/nvim/testdir/test_quickfix.vim | 41 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'src/nvim/testdir/test_quickfix.vim') diff --git a/src/nvim/testdir/test_quickfix.vim b/src/nvim/testdir/test_quickfix.vim index 9fbd3d25bd..f775b77ca0 100644 --- a/src/nvim/testdir/test_quickfix.vim +++ b/src/nvim/testdir/test_quickfix.vim @@ -3319,3 +3319,44 @@ func Test_lfile_crash() call assert_fails('lfile', 'E40') au! QuickFixCmdPre endfunc + +" Tests for quickfix/location lists changed by autocommands when +" :vimgrep/:lvimgrep commands are running. +func Test_vimgrep_autocmd() + call setqflist([], 'f') + call writefile(['stars'], 'Xtest1.txt') + call writefile(['stars'], 'Xtest2.txt') + + " Test 1: + " When searching for a pattern using :vimgrep, if the quickfix list is + " changed by an autocmd, the results should be added to the correct quickfix + " list. + autocmd BufRead Xtest2.txt cexpr '' | cexpr '' + silent vimgrep stars Xtest*.txt + call assert_equal(1, getqflist({'nr' : 0}).nr) + call assert_equal(3, getqflist({'nr' : '$'}).nr) + call assert_equal('Xtest2.txt', bufname(getqflist()[1].bufnr)) + au! BufRead Xtest2.txt + + " Test 2: + " When searching for a pattern using :vimgrep, if the quickfix list is + " freed, then a error should be given. + silent! %bwipe! + call setqflist([], 'f') + autocmd BufRead Xtest2.txt for i in range(10) | cexpr '' | endfor + call assert_fails('vimgrep stars Xtest*.txt', 'E925:') + au! BufRead Xtest2.txt + + " Test 3: + " When searching for a pattern using :lvimgrep, if the location list is + " freed, then the command should error out. + silent! %bwipe! + let g:save_winid = win_getid() + autocmd BufRead Xtest2.txt call setloclist(g:save_winid, [], 'f') + call assert_fails('lvimgrep stars Xtest*.txt', 'E926:') + au! BufRead Xtest2.txt + + call delete('Xtest1.txt') + call delete('Xtest2.txt') + call setqflist([], 'f') +endfunc -- cgit From 7d345a7294a24e8270bf608dd87d1ebd8c897432 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Thu, 6 Jun 2019 05:22:55 -0400 Subject: vim-patch:8.0.1784: gvim test gets stuck in dialog Problem: Gvim test gets stuck in dialog. Solution: Rename the file used. https://github.com/vim/vim/commit/bc7845da935c0707e119812077cecd6cfb5a65e2 --- src/nvim/testdir/test_quickfix.vim | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/nvim/testdir/test_quickfix.vim') diff --git a/src/nvim/testdir/test_quickfix.vim b/src/nvim/testdir/test_quickfix.vim index f775b77ca0..12cd07a772 100644 --- a/src/nvim/testdir/test_quickfix.vim +++ b/src/nvim/testdir/test_quickfix.vim @@ -1139,18 +1139,18 @@ func Test_efm2() " Test for %o set efm=%f(%o):%l\ %m - cgetexpr ['Xtestfile(Language.PureScript.Types):20 Error'] - call writefile(['Line1'], 'Xtestfile') + cgetexpr ['Xotestfile(Language.PureScript.Types):20 Error'] + call writefile(['Line1'], 'Xotestfile') let l = getqflist() call assert_equal(1, len(l), string(l)) call assert_equal('Language.PureScript.Types', l[0].module) copen call assert_equal('Language.PureScript.Types|20| Error', getline(1)) call feedkeys("\", 'xn') - call assert_equal('Xtestfile', expand('%:t')) + call assert_equal('Xotestfile', expand('%:t')) cclose bd - call delete("Xtestfile") + call delete("Xotestfile") " The following sequence of commands used to crash Vim set efm=%W%m -- cgit From bb4e0deaf924490f792433becbe0629fe0ce5b4e Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Thu, 6 Jun 2019 19:59:17 -0400 Subject: vim-patch:8.1.0060: crash when autocommands delete the current buffer Problem: Crash when autocommands delete the current buffer. (Dominique Pelle) Solution: Check that autocommands don't change the buffer. https://github.com/vim/vim/commit/600323b4ef51a58a8e800d8ca469383a3c911db7 --- src/nvim/testdir/test_quickfix.vim | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/nvim/testdir/test_quickfix.vim') diff --git a/src/nvim/testdir/test_quickfix.vim b/src/nvim/testdir/test_quickfix.vim index 12cd07a772..16fb86ea08 100644 --- a/src/nvim/testdir/test_quickfix.vim +++ b/src/nvim/testdir/test_quickfix.vim @@ -3360,3 +3360,15 @@ func Test_vimgrep_autocmd() call delete('Xtest2.txt') call setqflist([], 'f') endfunc + +func Test_lbuffer_with_bwipe() + new + new + augroup nasty + au * * bwipe + augroup END + lbuffer + augroup nasty + au! + augroup END +endfunc -- cgit