Since the Location List needs to be associated with a window, that is, the entries displayed in the Location List correspond to a specific window ID (referred to as the "business window"). In addition, the Location List itself also has a window ID (referred to as the "Location List window").
When the quickfixtextfunc option is set to a custom function:
When executing :lvimgrep directly via an Ex command, the window ID obtained via a:info.winid in the custom function is the ID of the business window (correct);
However, if the lvimgrep command is wrapped inside a custom function, a:info.winid shows the ID of the Location List window instead (incorrect).
Nevertheless, within the custom function specified by the quickfixtextfunc option, in order to obtain the contents of the Location List, the only way is to call the getloclist() function. However, this function requires the business window ID to be specified. Since the interface of the custom function is fixed (it only accepts a single dictionary parameter info) and is invoked automatically by Vim, this makes it impossible to obtain the correct business window ID, and consequently, the contents cannot be retrieved via getloclist().
A workaround solution is to use getwinvar() to check the &buftype attribute of that window. If it is quickfix, use the ID of its previous window (#); otherwise, use the current window ID.
if getwinvar(a:info.winid, '&buftype') == 'quickfix'
let file_winid = win_getid(winnr('#'))
else
let file_winid = a:info.winid
endif
In all cases, the winid in info should always return the associated "business window ID", rather than — as happens when lvimgrep is executed within a custom function — returning the ID of the Location List window itself.
vim 9.1.821
window 11
—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.![]()
Where are the "steps" in "Steps to reproduce"?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.![]()