Support using lambda function for quickfixtestfunc#6499
Support using lambda function for quickfixtestfunc#6499yegappan wants to merge 2 commits intovim:masterfrom
Conversation
Codecov Report
@@ Coverage Diff @@
## master #6499 +/- ##
==========================================
- Coverage 88.26% 88.10% -0.16%
==========================================
Files 144 144
Lines 159516 156786 -2730
==========================================
- Hits 140803 138144 -2659
+ Misses 18713 18642 -71
Continue to review full report at Codecov.
|
|
Thank you. Allowing a lambda for the global |
|
Hi,
On Mon, Jul 20, 2020 at 1:57 AM bfrg ***@***.***> wrote:
Thank you. Allowing a lambda for the global 'quickfixtextfunc' is
inconsistent with other global options that support only global functions,
or am I wrong on this?
I recently sent an email to the list about the support for using lambda
functions with
the following options:
balloonexpr, charconvert, completefunc, diffexpr, foldexpr, foldtext,
formatexpr, imactivatefunc, imstatusfunc, includeexpr, indentexpr,
omnifunc, operatorfunc, patchexpr, printexpr, quickfixtextfunc, tagfunc
Bram responded to the email stating that it will be useful to support it
for these options.
Regards,
Yegappan
|
|
Thank you very much for working on this. I can confirm that you can now use a lambda, and even a funcref. Tested in 2 different plugins; both work as expected.
This works as documented.
However, this doesn't seem to work: set efm=%f
fu Func()
call setqflist([], ' ', {
\ 'lines': v:oldfiles,
\ 'efm': '%f',
\ 'quickfixtextfunc': 'Qftf',
\ })
cw
endfu
fu Qftf(info)
let qfl = getqflist(#{id: a:info.id, items: 0}).items
let l = []
for idx in range(a:info.start_idx - 1, a:info.end_idx - 1)
let e = qfl[idx]
if idx % 3 == 2
call add(l, '')
else
call add(l, bufname(e.bufnr))
endif
endfor
return l
endfu
call Func()I would expect every third line to be formatted with the default format, which here is |
|
Here's a shell one-liner to illustrate: |
|
Hi,
On Mon, Jul 20, 2020 at 8:52 AM lacygoill ***@***.***> wrote:
Thank you very much for working on this.
I can confirm that you can now use a lambda, and even a funcref. Tested in
2 different plugins; both work as expected.
Thanks for testing the changes. Note that the global option
"quickfixtextfunc" only supports
either a function name or a lambda. You cannot use a funcref with this. But
you can use it
with the setqflist() and setloclist() functions.
------------------------------
If an empty list is returned, then the
default format is used to display all the entries.
This works as documented.
If an item in the returned
list is an empty string, then the default format is used to display the
corresponding entry.
However, this doesn't seem to work:
I have updated the PR with a fix for this.
Regards,
Yegappan
… set efm=%ffu Func()
call setqflist([], ' ', {
\ 'lines': v:oldfiles,
\ 'efm': '%f',
\ 'quickfixtextfunc': 'Qftf',
\ })
cwendfu
fu Qftf(info)
let qfl = getqflist(#{id: a:info.id, items: 0}).items
let l = []
for idx in range(a:info.start_idx - 1, a:info.end_idx - 1)
let e = qfl[idx]
if idx % 3 == 2
call add(l, '')
else
call add(l, bufname(e.bufnr))
endif
endfor
return lendfu
call Func()
I would expect every third line to be formatted with the default format,
which here is %f. IOW, I would expect to see a filename in the quickfix
window. Instead, every third line is empty. Maybe I'm doing something wrong
though. I'll try to re-read the documentation and make more tests.
|
|
Can confirm that the latest commit fixes the issue; thank you again. |
Problem: Cannot use a lambda with quickfix functions. Solution: Add support for lambda. (Yegappan Lakshmanan, closes vim/vim#6499) vim/vim@d43906d Comment out some tests because function('') cannot be asserted.
Problem: Cannot use a lambda with quickfix functions. Solution: Add support for lambda. (Yegappan Lakshmanan, closes vim/vim#6499) vim/vim@d43906d
Problem: Cannot use a lambda with quickfix functions. Solution: Add support for lambda. (Yegappan Lakshmanan, closes vim/vim#6499) vim/vim@d43906d
Problem: Cannot use a lambda with quickfix functions. Solution: Add support for lambda. (Yegappan Lakshmanan, closes vim/vim#6499) vim/vim@d43906d
Problem: Cannot use a lambda with quickfix functions. Solution: Add support for lambda. (Yegappan Lakshmanan, closes vim/vim#6499) vim/vim@d43906d
No description provided.