# lsp: Check which code actions are supported before request \(\#14666\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/22a2cc69508d196a592d85cb1bb74b5942ec7b09)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 22a2cc69508d196a592d85cb1bb74b5942ec7b09

Requested commit: 22a2cc69508d196a592d85cb1bb74b5942ec7b09

Commit: 22a2cc69508d196a592d85cb1bb74b5942ec7b09

Tree: 371d7ea5e56610b0b80d67f22ad2180f435c0ed0

Author: Thorsten Ball

Committer: GitHub

## Message

```
lsp: Check which code actions are supported before request (#14666)

This fixes https://github.com/zed-industries/zed/issues/13633 by not
sending `source.organizeImports` to the ESLint language server anymore.

Turns out that ESLint tells us through its capabilities that it doesn't
support that code action kind, but we ignored that.

What this code does is to check whether a given server supports specific
code action kinds.

It does this in two places:

1. When constructing the request: we now filter down the list of
   requested `kinds`, in case we can do so. If we can't filter down the
   list, we keep the previous behavior of sending the
   `language_server.code_action_kinds()`
2. Before sending the request: we now check whether the server even
   supports sending the request.

This fixes the issue by only sending actions to servers that support it.

I tested this with various language servers and setups and everything
still works (or works better). But of course there are a ton of
different combinations of language servers and code actions and file
types, so I couldn't test them all.

Release Notes:

- Fix ESLint language server adding comments on save if the
`source.organizeImports` code action was used on save. Zed now filters
out code actions sent to the language servers by checking whether they
are supported first.
([#13633](https://github.com/zed-industries/zed/issues/13633)).
```

## Parents

- [49effeb7bac37d093ceebed8111e544254ea8b7e](https://git.cafe/gitcafe/zed/commit/49effeb7bac37d093ceebed8111e544254ea8b7e?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/22a2cc69508d196a592d85cb1bb74b5942ec7b09?format=markdown)
