quickfix: no efficient way to get error type counts#20434
Conversation
Problem: There is no efficient way to get the count of each error type
in a quickfix list. Retrieving this information requires
iterating over the entire list in script, which is O(N).
Solution: Maintain a type-frequency histogram in 'qf_list_T' and expose
it via the 'total' key in getqflist() and getloclist().
(yilisharcs)
Co-authored-by: Gemini 3 Flash
Signed-off-by: yilisharcs <yilisharcs@gmail.com>
|
i don't know how else to improve this. and i did spend a reasonable amount of time on it. all that's left is for people with actual experience with the vim internals to have a look. i promise i did not vibecode this. |
|
Thanks for the work and the explanation — and no concern about how it was There are a few correctness issues and a design 1. Multiline
|
so, funny thing... i would have made tests/ran the test suite if trying to build vim from source (with no changes!) and set $VIMRUNTIME didn't cause it to crash with a buffer overflow on launch. i'm pretty sure this is something about my nixos environment, but i had hoped i could sidestep this for now... regarding all others, thanks! i will act on your advice UPDATE: it was nixos... fortify3... |
|
1 & 2. currently looking into it
i'm making a (neovim) plugin that uses async jobs and the quickfix list to make something like emacs' compilation mode. it currently has this loop-- local items = vim.fn.getqflist({ lines = batch, efm = ctx.efm }).items
for _, item in ipairs(items) do
if item.valid == 1 then
local t = (item.type and item.type ~= "") and item.type:upper() or "I"
local key = ctx.counts[t] and t or "I"
ctx.counts[key] = ctx.counts[key] + 1
end
end--to keep a live count of the valid entries on the statusline. it's not rare for me in the sense that i was testing it with ripgrep (which was slow to stream the data into the quickfix list, but that's a whole another PR) on my home directory, so that naive loop would be called thousands of times per second. now assuming i haven't misunderstood how neovim interfaces with this structure, for the data to get from the core to my plugin i first have to call
|

Problem: There is no efficient way to get the count of each error type
in a quickfix list. Retrieving this information requires
iterating over the entire list in script, which is O(N).
Solution: Maintain a type-frequency histogram in 'qf_list_T' and expose
it via the 'total' key in getqflist() and getloclist().
(yilisharcs)
Co-authored-by: Gemini 3 Flash
Note: neovim/neovim#40110