-
Notifications
You must be signed in to change notification settings - Fork 184
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
Request code actions at the cursor/selection when the selection is modified #1085
Comments
I can do it after finishing CAOS (soon, I think). I'd want to avoid conflicting changes for now :) |
I wonder if it's again because of custom handling in the extension that makes this server trigger code actions on selection change. It doesn't look like VSCode triggers code actions on selection change for other servers (tried eslint). Here is some relevant code but it doesn't give me a clear answer: https://github.com/rust-analyzer/rust-analyzer/blob/4029628f15c612182ad9da1c652078f9df62f5cf/editors/code/src/client.ts#L69-L71 If that middleware is called on every selection change then that would explain the behavior but then do we really want to do the same for every server? And then there is also this comment in that code:
which doesn't really seem to be the case. EDIT: Actually that seems right. It receives edit-less code actions and creates "commands" from them. |
Also, it builds somewhat custom code actions in that code so, since we don't do that, those code actions wouldn't work for us anyway.
So this behavior might be wanted anyway but rust-analyzer will still not function properly. And we might want to consider performance impact of triggering code actions on all cursor movements (even when typing). |
- When requesting code actions using keyboard action, take whole selection range into account rather than just selection end point. - Move code action requesting code into CodeActionsManager class to have one common endpoint. "request_code_actions" is left outside because it's imported by tests (but technically could also move it inside). - (WIP) Trigger code actions on selection changes. This uses new ST4 annotations feature to show the number of available code actions. It's better than bulb as bulb can't be clicked. The underline of the link looks a bit wrong in the annotation (seems like an ST bug). Also, it's not clear if we really want this feature. Maybe if we optimize it to not trigger for *all* selection changes (so also when typing). - I guess we could support all selections for this feature instead of only the first one. Resolves #1085
- When requesting code actions using keyboard action, take whole selection range into account rather than just selection end point. - Move code action requesting code into CodeActionsManager class to have one common endpoint. "get_matching_kinds" is left outside because it's imported by tests (but technically could also move it inside). - (WIP) Trigger code actions on selection changes. This uses new ST4 annotations feature to show the number of available code actions. It's better than bulb as bulb can't be clicked. The underline of the link looks a bit wrong in the annotation (seems like an ST bug). Also, it's not clear if we really want this feature. Maybe if we optimize it to not trigger for *all* selection changes (so also when typing). - I guess we could support all selections for this feature instead of only the first one. Resolves #1085
- When requesting code actions using keyboard action, take whole selection range into account rather than just selection end point. - Move code action requesting code into CodeActionsManager class to have one common endpoint. "get_matching_kinds" is left outside because it's imported by tests (but technically could also move it inside). - (WIP) Trigger code actions on selection changes. This uses new ST4 annotations feature to show the number of available code actions. It's better than bulb as bulb can't be clicked. The underline of the link looks a bit wrong in the annotation (seems like an ST bug). Also, it's not clear if we really want this feature. Maybe if we optimize it to not trigger for *all* selection changes (so also when typing). - I guess we could support all selections for this feature instead of only the first one. Resolves #1085
Implemented by #1109 |
The rust-analyzer language server makes use of VSCode's behavior to request "diagnostic-less" code actions at the cursor whenever it changes. A user reported this on discord. We should mirror the behavior. This has already been observed and discussed here.
Because code-actions returned from this type of request do not belong to any diagnostics, we may have to adjust the internal design of the code a little for this feature. For example, we should invalidate those type of code actions whenever the buffer is modified. Most likely we can re-use the logic present in highlights.py or color.py.
Also, the user cannot "see" these code actions unless they turned on the gutter bulb.
The text was updated successfully, but these errors were encountered: