diff options
| author | kevinhwang91 <kevin.hwang@live.com> | 2021-05-04 13:57:00 +0800 |
|---|---|---|
| committer | kevinhwang91 <kevin.hwang@live.com> | 2021-05-20 00:24:22 +0800 |
| commit | 19d4926f5a4390b4d96ea1638cc08e7798e625e2 (patch) | |
| tree | 4eaf125942e44f2edd1e37c6aa7d97507cc9a6c4 /src/nvim/testdir | |
| parent | 00246d7be550cf990dac7e49903519f5dd68e89c (diff) | |
| download | rneovim-19d4926f5a4390b4d96ea1638cc08e7798e625e2.tar.gz rneovim-19d4926f5a4390b4d96ea1638cc08e7798e625e2.tar.bz2 rneovim-19d4926f5a4390b4d96ea1638cc08e7798e625e2.zip | |
vim-patch:8.2.0959: using 'quickfixtextfunc' is a bit slow
Problem: Using 'quickfixtextfunc' is a bit slow.
Solution: Process a list of entries. (Yegappan Lakshmanan, closes vim/vim#6234)
https://github.com/vim/vim/commit/00e260bb6cc33ff5dbba15ac87ca7fd465aa49c0
Diffstat (limited to 'src/nvim/testdir')
| -rw-r--r-- | src/nvim/testdir/test_quickfix.vim | 59 |
1 files changed, 39 insertions, 20 deletions
diff --git a/src/nvim/testdir/test_quickfix.vim b/src/nvim/testdir/test_quickfix.vim index ed83a96906..06a0fd5001 100644 --- a/src/nvim/testdir/test_quickfix.vim +++ b/src/nvim/testdir/test_quickfix.vim @@ -4809,24 +4809,27 @@ endfunc " Test for the 'quickfixtextfunc' setting func Tqfexpr(info) if a:info.quickfix - let qfl = getqflist({'id' : a:info.id, 'idx' : a:info.idx, - \ 'items' : 1}).items + let qfl = getqflist({'id' : a:info.id, 'items' : 1}).items else - let qfl = getloclist(a:info.winid, {'id' : a:info.id, 'idx' : a:info.idx, - \ 'items' : 1}).items + let qfl = getloclist(a:info.winid, {'id' : a:info.id, 'items' : 1}).items endif - let e = qfl[0] - let s = '' - if e.bufnr != 0 - let bname = bufname(e.bufnr) - let s ..= fnamemodify(bname, ':.') - endif - let s ..= '-' - let s ..= 'L' .. string(e.lnum) .. 'C' .. string(e.col) .. '-' - let s ..= e.text - return s + let l = [] + for idx in range(a:info.start_idx - 1, a:info.end_idx - 1) + let e = qfl[idx] + let s = '' + if e.bufnr != 0 + let bname = bufname(e.bufnr) + let s ..= fnamemodify(bname, ':.') + endif + let s ..= '-' + let s ..= 'L' .. string(e.lnum) .. 'C' .. string(e.col) .. '-' + let s ..= e.text + call add(l, s) + endfor + + return l endfunc func Xtest_qftextfunc(cchar) @@ -4850,16 +4853,18 @@ func Xtest_qftextfunc(cchar) " Test for per list 'quickfixtextfunc' setting func PerQfText(info) if a:info.quickfix - let qfl = getqflist({'id' : a:info.id, 'idx' : a:info.idx, - \ 'items' : 1}).items + let qfl = getqflist({'id' : a:info.id, 'items' : 1}).items else - let qfl = getloclist(a:info.winid, {'id' : a:info.id, 'idx' : a:info.idx, - \ 'items' : 1}).items + let qfl = getloclist(a:info.winid, {'id' : a:info.id, 'items' : 1}).items endif if empty(qfl) - return '' + return [] endif - return 'Line ' .. qfl[0].lnum .. ', Col ' .. qfl[0].col + let l = [] + for idx in range(a:info.start_idx - 1, a:info.end_idx - 1) + call add(l, 'Line ' .. qfl[idx].lnum .. ', Col ' .. qfl[idx].col) + endfor + return l endfunc set quickfixtextfunc=Tqfexpr call g:Xsetlist([], ' ', {'quickfixtextfunc' : "PerQfText"}) @@ -4902,8 +4907,22 @@ func Xtest_qftextfunc(cchar) Xexpr ['F1:10:2:green', 'F1:20:4:blue']" call assert_fails("Xwindow", 'E119:') Xclose + + " set option to a function that returns a list with non-strings + func Xqftext2(d) + return ['one', [], 'two'] + endfunc + set quickfixtextfunc=Xqftext2 + " call assert_fails("Xexpr ['F1:10:2:green', 'F1:20:4:blue', 'F1:30:6:red']", + " \ 'E730:') + Xexpr ['F1:10:2:green', 'F1:20:4:blue', 'F1:30:6:red'] + call assert_fails('Xwindow', 'E730:') + call assert_equal(['one', 'F1|20 col 4| blue', 'two'], getline(1, '$')) + Xclose + set quickfixtextfunc& delfunc Xqftext + delfunc Xqftext2 endfunc func Test_qftextfunc() |