mirror of
https://github.com/vim/vim.git
synced 2025-09-29 04:34:16 -04:00
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 #6234)
This commit is contained in:
@@ -4818,24 +4818,26 @@ 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
|
||||
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 s
|
||||
return l
|
||||
endfunc
|
||||
|
||||
func Xtest_qftextfunc(cchar)
|
||||
@@ -4859,16 +4861,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"})
|
||||
@@ -4908,8 +4912,21 @@ func Xtest_qftextfunc(cchar)
|
||||
call assert_fails("Xexpr ['F1:10:2:green', 'F1:20:4:blue']", 'E119:')
|
||||
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:')
|
||||
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()
|
||||
|
Reference in New Issue
Block a user