10000 fix(quickfix): add event QuickFixChanged by glepnir · Pull Request #16216 · vim/vim · GitHub
[go: up one dir, main page]

Skip to content

fix(quickfix): add event QuickFixChanged #16216

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

glepnir
Copy link
Member
@glepnir glepnir commented Dec 14, 2024

this event is trigger after calling of setqflist and setloclist

context neovim/neovim#13099

src/quickfix.c Outdated
@@ -8044,6 +8045,9 @@ set_errorlist(
qf_list_changed(qf_get_curlist(qi));
}

qfbuf = buflist_findnr(qi->qf_bufnr);
apply_autocmds(EVENT_QUICKFIXCMDCHANGED, NULL, NULL, FALSE, qfbuf);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the use case for this autocmd? What happens if the quickfix list or location list is modified from this autocmd?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, you can use the QuickFixCmdPost event to, e.g., open a quickfix or location list window if a command has filled the list with something to work on. (For example, here.) But if you fill the lists using setqflist or setloclist, then the QuickFixCmdPost event is not triggered. In that case, you have to manually create and fire a dummy autocommand for users to hook into. E.g., here. This additional autocommand event would help users and plugin authors that fill the quickfix or location lists with setqflist and setloclist.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also what happens if you move to a different quickfix or location list in the stack? What if you :bw the buffer?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

after use setqflist or setloclist before copen lopen in this case qfbuf is NULL do we want also trigger ? i do trigger here

Copy link
Member Author
@glepnir glepnir Dec 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@telemachus moved to trigger on qf_list_changed. But this function runs before qf_update_buffer. Meaning that when the event triggers the qfbuffer may not be updated. Does this have any impact.

Edit: I have updated there. see test case. if useful

@chrisbra
Copy link
Member

Thanks, but I'd like to see few more tests, which modifies the quickfix/locationlist, verify this is also been called by e.g. :vimgrep command or other quickfix commands or removes the window.

Also I am wondering, shouldn't this autocommand be called QuickFixChanged ? And finally, do we need to know which command/expr modified the quickfix list?

@glepnir glepnir changed the title fix(quickfix): add event QuickFixCmdChanged fix(quickfix): add event QuickFixChanged Dec 15, 2024
@glepnir glepnir force-pushed the event_qfchanged branch 2 times, most recently from 4043a97 to 2e95824 Compare December 15, 2024 03:31
@glepnir
Copy link
Member Author
glepnir commented Dec 15, 2024

And finally, do we need to know which command/expr modified the quickfix list?

currently this is used for calling function there is no command to record and if we want to command does this not already known by au_name apply_autocmds(EVENT_QUICKFIXCMDPRE, au_name,

@bfrg
Copy link
Contributor
bfrg commented Dec 17, 2024

I think, it would be helpful to set v:event to a dict containing the id of the quickfix list that was changed when QuickfixChanged is triggered. Otherwise, how do users know which quickfix list was changed?

@glepnir glepnir force-pushed the event_qfchanged branch 3 times, most recently from 11649fb to 82c5631 Compare January 2, 2025 10:14
this event is trigger after calling of setqflist and setloclist
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.

5 participants
0