Mercurial > vim
comparison src/testdir/test_quickfix.vim @ 13594:4d55eb79178b v8.0.1669
patch 8.0.1669: :vimgrep may add entries to the wrong quickfix list
commit https://github.com/vim/vim/commit/e1bb879f49665bb828197135b80aaf72cc190073
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Apr 6 22:58:23 2018 +0200
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)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Fri, 06 Apr 2018 23:00:08 +0200 |
parents | 9812a9ca3ab2 |
children | 89223f5d5d12 |
comparison
equal
deleted
inserted
replaced
13593:1e1e371e8a4c | 13594:4d55eb79178b |
---|---|
3109 " open right of the current window | 3109 " open right of the current window |
3110 rightbelow copen | 3110 rightbelow copen |
3111 call assert_equal(3, winnr()) | 3111 call assert_equal(3, winnr()) |
3112 close | 3112 close |
3113 endfunc | 3113 endfunc |
3114 | |
3115 " Tests for quickfix/location lists changed by autocommands when | |
3116 " :vimgrep/:lvimgrep commands are running. | |
3117 func Test_vimgrep_autocmd() | |
3118 call setqflist([], 'f') | |
3119 call writefile(['stars'], 'Xtest1.txt') | |
3120 call writefile(['stars'], 'Xtest2.txt') | |
3121 | |
3122 " Test 1: | |
3123 " When searching for a pattern using :vimgrep, if the quickfix list is | |
3124 " changed by an autocmd, the results should be added to the correct quickfix | |
3125 " list. | |
3126 autocmd BufRead Xtest2.txt cexpr '' | cexpr '' | |
3127 silent vimgrep stars Xtest*.txt | |
3128 call assert_equal(1, getqflist({'nr' : 0}).nr) | |
3129 call assert_equal(3, getqflist({'nr' : '$'}).nr) | |
3130 call assert_equal('Xtest2.txt', bufname(getqflist()[1].bufnr)) | |
3131 au! BufRead Xtest2.txt | |
3132 | |
3133 " Test 2: | |
3134 " When searching for a pattern using :vimgrep, if the quickfix list is | |
3135 " freed, then a error should be given. | |
3136 silent! %bwipe! | |
3137 call setqflist([], 'f') | |
3138 autocmd BufRead Xtest2.txt for i in range(10) | cexpr '' | endfor | |
3139 call assert_fails('vimgrep stars Xtest*.txt', 'E925:') | |
3140 au! BufRead Xtest2.txt | |
3141 | |
3142 " Test 3: | |
3143 " When searching for a pattern using :lvimgrep, if the location list is | |
3144 " freed, then the command should error out. | |
3145 silent! %bwipe! | |
3146 let g:save_winid = win_getid() | |
3147 autocmd BufRead Xtest2.txt call setloclist(g:save_winid, [], 'f') | |
3148 call assert_fails('lvimgrep stars Xtest*.txt', 'E926:') | |
3149 au! BufRead Xtest2.txt | |
3150 | |
3151 call delete('Xtest1.txt') | |
3152 call delete('Xtest2.txt') | |
3153 call setqflist([], 'f') | |
3154 endfunc |