-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Filter LSP code actions based on the requested kinds #20847
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cla-bot
bot
added
the
cla-signed
The user has signed the Contributor License Agreement
label
Nov 19, 2024
osiewicz
reviewed
Nov 19, 2024
osiewicz
reviewed
Nov 19, 2024
Techatrix
force-pushed
the
filter-code-actions
branch
from
November 19, 2024 02:10
893b1f6
to
b447bf4
Compare
Co-authored-by: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com>
Techatrix
force-pushed
the
filter-code-actions
branch
from
November 19, 2024 02:17
7e9d115
to
004195f
Compare
Passing by and suggesting to add a test for this. zed/crates/project/src/project_tests.rs Line 4965 in 81ca890
|
Techatrix
force-pushed
the
filter-code-actions
branch
from
November 22, 2024 10:55
8be6a95
to
fe8ac46
Compare
osiewicz
approved these changes
Nov 22, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Anthony-Eid
pushed a commit
to Anthony-Eid/zed
that referenced
this pull request
Nov 22, 2024
…20847) I've observed that Zed's implementation of [Code Actions On Format](https://zed.dev/docs/configuring-zed#code-actions-on-format) uses the [CodeActionContext.only](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#codeActionContext) parameter to request specific code action kinds from the server. The issue is that it does not filter out code actions from the response, believing that the server will do it. The [LSP specification](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#codeActionContext) says that the client is responsible for filtering out unwanted code actions: ```js /** * Requested kind of actions to return. * * Actions not of this kind are filtered out by the client before being * shown. So servers can omit computing them. */ only?: CodeActionKind[]; ``` This PR will filter out unwanted code action on the client side. I have initially encountered this issue because the [ZLS language server](https://github.com/zigtools/zls) (until zigtools/zls#2087) does not filter code action based on `CodeActionContext.only` so Zed runs all received code actions even if they are explicitly disabled in the `code_actions_on_format` setting. Release Notes: - Fix the `code_actions_on_format` setting when used with a language server like ZLS --------- Co-authored-by: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
I've observed that Zed's implementation of Code Actions On Format uses the CodeActionContext.only parameter to request specific code action kinds from the server. The issue is that it does not filter out code actions from the response, believing that the server will do it.
The LSP specification says that the client is responsible for filtering out unwanted code actions:
This PR will filter out unwanted code action on the client side.
I have initially encountered this issue because the ZLS language server (until zigtools/zls#2087) does not filter code action based on
CodeActionContext.only
so Zed runs all received code actions even if they are explicitly disabled in thecode_actions_on_format
setting.Release Notes:
code_actions_on_format
setting when used with a language server like ZLS