-
-
Notifications
You must be signed in to change notification settings - Fork 389
Code action order could prefer fixes over disabling warnings #2057
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
Mmm i think in vim all the code actions are shown, not only the associated with the diagnostic, in vscode you could see them clicking in the light bulb at the start of the expression |
@jneira Seems no, all I can see while clicking the bulb is just the one hint. |
Maybe related with #2013??, does add import suggestions still works for you? |
The existence of remove unused imports is being exercised here afaics:
|
You may need to enable |
Oh yeah i forgot that "little" detail, thanks |
@pepeiborra Yes, it works! My order is a little different from the author's. @jneira I think enable |
Yeah we are doing it in hls itself for example, but i think we have to be precise in the documentation and note that this concrete warning (mentioning -Wall) is needed to make those code actions work at all. |
If I understand correctly, the current display order of code actions is up to how handlers are concatenated, which I think is hard to track around ghcide and HLS plugins. Moreover, take pragmas plugin as example, we want adding pragmas be the top priority in most cases (though it‘s supposed to be now, since parsing errors or typechecking errors caused by missing pragmas will prevent ghc from producing warnings), but disabling warnings be the lowest. This doesn't seem feasible by simply reordering handlers. |
Mmm so a proper solution could be change hls-plugin-api to being able to inform the priority of code actions? or it would need a even deeper change? |
How about a hack filter in
😆 |
HLS is absolutely amazing, and this would be a huge feature for the ergonomics of HLS. I'm firing off tons and tons of code actions every day, but it's often that the one I want is at the bottom of the suggested list. Maybe a first step would be to categorize code actions and then assign priorities to them? Just to understand the high-level design of something like this. Ones that I'm often reaching for are:
Things I'm often not trying to do that are frequently at the top:
Just some thoughts that might help. Anybody else have other ones? |
code actions has a kind field, which can be used (and it is used in fact) to filter or order them, see #1458 |
I think it would be difficult to reach a ordering which will satisfy all or even most users. So it should be configurable and make sense that clients have the responsability of doing that. |
There are There is a property
Defined |
I'm not sure if we return the code actions in any particular order. We do for completions, but I think code actions are pretty random. We could try and implement some sorting, but using |
Yes, I assume we could change order to be less random, but this would need a different way to make sure sorting is done across multiple plugins.
|
Changed in two cases: Will close the issue since the original examples should be improved. Anyhow, there might be more places where we could mark code actions as |
TL;DR
Code actions are ordered in a way where the most likely option is on the bottom.
Issue
I'm often using code actions to organize imports and remove the ones that aren't necessary. The option that is use the most often ("Remove all redundant imports") is the last option of the menu. And I think most of the time "Disable ... warnings" is the first option. "Make all imports implicit" seems not relevant here.
One issue is that one needs to move to the end of the list each time. But for example in CoC (Vim)
coc-fix-current
defines the top code action as default and will execute it. So changing the order could be an improvement.Potential Improvement
Change the order of code actions to (try to) match the most likely behavior. E.g. move "disable warnings" to the bottom of the suggested code actions by default.
Probe Tools
Config
https://github.com/andys8/dotfiles/blob/3c1d32349ffaf4c1ab840f7b340746846fb5e522/coc-settings.json#L34-L55
The text was updated successfully, but these errors were encountered: