Skip to content

Support using lambda function for quickfixtestfunc#6499

Closed
yegappan wants to merge 2 commits intovim:masterfrom
yegappan:qftf
Closed

Support using lambda function for quickfixtestfunc#6499
yegappan wants to merge 2 commits intovim:masterfrom
yegappan:qftf

Conversation

@yegappan
Copy link
Member

No description provided.

@codecov
Copy link

codecov bot commented Jul 20, 2020

Codecov Report

Merging #6499 into master will decrease coverage by 0.15%.
The diff coverage is 91.17%.

Impacted file tree graph

@@            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     
Impacted Files Coverage Δ
src/channel.c 89.47% <ø> (-0.36%) ⬇️
src/optionstr.c 93.67% <66.66%> (-0.16%) ⬇️
src/quickfix.c 94.71% <91.07%> (-0.30%) ⬇️
src/evalvars.c 96.05% <100.00%> (-0.04%) ⬇️
src/mbyte.c 78.64% <0.00%> (-1.23%) ⬇️
src/gui.c 62.62% <0.00%> (-1.04%) ⬇️
src/gui_gtk_x11.c 58.32% <0.00%> (-0.76%) ⬇️
src/textobject.c 91.69% <0.00%> (-0.71%) ⬇️
src/netbeans.c 75.71% <0.00%> (-0.66%) ⬇️
src/profiler.c 92.39% <0.00%> (-0.65%) ⬇️
... and 122 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b146e01...b7fc5f6. Read the comment docs.

@bfrg
Copy link
Contributor

bfrg commented Jul 20, 2020

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?

@vim-ml
Copy link

vim-ml commented Jul 20, 2020 via email

@lacygoill
Copy link

lacygoill commented Jul 20, 2020

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.


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:

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 %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.

@lacygoill
Copy link

Here's a shell one-liner to illustrate:

./src/vim -Nu NONE +'set efm=%f' +"call setqflist([], ' ', {'lines': v:oldfiles, 'efm': '%f', 'quickfixtextfunc': {d -> repeat([''], d.end_idx - d.start_idx + 1)}})" +cw

@vim-ml
Copy link

vim-ml commented Jul 20, 2020 via email

@lacygoill
Copy link

Can confirm that the latest commit fixes the issue; thank you again.

@brammool brammool closed this in d43906d Jul 20, 2020
janlazo added a commit to janlazo/neovim that referenced this pull request Jun 23, 2021
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.
janlazo added a commit to janlazo/neovim that referenced this pull request Jun 24, 2021
Problem:    Cannot use a lambda with quickfix functions.
Solution:   Add support for lambda. (Yegappan Lakshmanan, closes vim/vim#6499)
vim/vim@d43906d
janlazo added a commit to janlazo/neovim that referenced this pull request Jun 24, 2021
Problem:    Cannot use a lambda with quickfix functions.
Solution:   Add support for lambda. (Yegappan Lakshmanan, closes vim/vim#6499)
vim/vim@d43906d
janlazo added a commit to janlazo/neovim that referenced this pull request Jun 24, 2021
Problem:    Cannot use a lambda with quickfix functions.
Solution:   Add support for lambda. (Yegappan Lakshmanan, closes vim/vim#6499)
vim/vim@d43906d
akinsho pushed a commit to akinsho/neovim that referenced this pull request Jun 25, 2021
Problem:    Cannot use a lambda with quickfix functions.
Solution:   Add support for lambda. (Yegappan Lakshmanan, closes vim/vim#6499)
vim/vim@d43906d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants