fix(lsp): require config and code actions #6557
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR closes two bugs.
Closes #6287
To fix this bug, I had to apply the following changes:
ConfigurationStatus::Missed
.textDocument/codeAction
must be registered dynamically. We already do so with formatting requests too.The second bug was related to how we compute the code actions to provide to the editors. I must admit that there was a lot of confusion on my part (and possibly others') in understanding the feature and correctly applying it to the code.
When the client requests
textDocument/codeAction
, we simply need to provide the code actions available to a diagnostic. Those code actions are the ones that belong to the choices that the editor provides when clicking Cmd + .. This means that we need to provide ALL code actions: the safe fix, the inline suppression and the top-level suppression. The user will choose what they want.When configuring
codeActionsOnSave
/code_actions_on_format
, the user chooses which ones should be applied among the ones listed.Given the previous statements, I adjusted the code, and I also added and fixed some checks: we now check both assist and linter.
Important
There's still a small bug where we provide suppressions regardless of whether the action is a lint rule or an assist action. This requires some refactoring that I prefer to tackle in a different PR.
I also updated the label of the
fixAll
action. This is how it looks like:Test Plan
I did manual testing in Zed and VSCode and made sure they behave the same.
Updated the tests, and removed one test that doesn't make sense anymore.