Commit 85656bf
Filter LSP code actions based on the requested kinds (zed-industries#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>1 parent 3cc51b1 commit 85656bf
File tree
6 files changed
+116
-18
lines changed- crates
- collab/src/tests
- editor/src
- project/src
6 files changed
+116
-18
lines changedLines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
835 | 835 | | |
836 | 836 | | |
837 | 837 | | |
838 | | - | |
| 838 | + | |
839 | 839 | | |
840 | 840 | | |
841 | 841 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13811 | 13811 | | |
13812 | 13812 | | |
13813 | 13813 | | |
13814 | | - | |
| 13814 | + | |
| 13815 | + | |
| 13816 | + | |
13815 | 13817 | | |
13816 | 13818 | | |
13817 | 13819 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2090 | 2090 | | |
2091 | 2091 | | |
2092 | 2092 | | |
| 2093 | + | |
| 2094 | + | |
| 2095 | + | |
| 2096 | + | |
| 2097 | + | |
| 2098 | + | |
2093 | 2099 | | |
2094 | 2100 | | |
2095 | 2101 | | |
2096 | 2102 | | |
2097 | | - | |
2098 | | - | |
2099 | | - | |
2100 | | - | |
2101 | | - | |
2102 | | - | |
2103 | | - | |
2104 | | - | |
| 2103 | + | |
| 2104 | + | |
| 2105 | + | |
| 2106 | + | |
| 2107 | + | |
| 2108 | + | |
| 2109 | + | |
| 2110 | + | |
| 2111 | + | |
| 2112 | + | |
2105 | 2113 | | |
| 2114 | + | |
| 2115 | + | |
| 2116 | + | |
| 2117 | + | |
| 2118 | + | |
| 2119 | + | |
2106 | 2120 | | |
2107 | 2121 | | |
2108 | 2122 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2015 | 2015 | | |
2016 | 2016 | | |
2017 | 2017 | | |
| 2018 | + | |
2018 | 2019 | | |
2019 | 2020 | | |
2020 | 2021 | | |
| |||
2028 | 2029 | | |
2029 | 2030 | | |
2030 | 2031 | | |
2031 | | - | |
| 2032 | + | |
2032 | 2033 | | |
2033 | 2034 | | |
2034 | 2035 | | |
| |||
2054 | 2055 | | |
2055 | 2056 | | |
2056 | 2057 | | |
2057 | | - | |
| 2058 | + | |
2058 | 2059 | | |
2059 | 2060 | | |
2060 | 2061 | | |
| |||
2079 | 2080 | | |
2080 | 2081 | | |
2081 | 2082 | | |
2082 | | - | |
| 2083 | + | |
2083 | 2084 | | |
2084 | 2085 | | |
2085 | 2086 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | | - | |
56 | | - | |
| 55 | + | |
| 56 | + | |
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| |||
2843 | 2843 | | |
2844 | 2844 | | |
2845 | 2845 | | |
| 2846 | + | |
2846 | 2847 | | |
2847 | 2848 | | |
2848 | 2849 | | |
2849 | 2850 | | |
2850 | 2851 | | |
2851 | | - | |
| 2852 | + | |
2852 | 2853 | | |
2853 | 2854 | | |
2854 | 2855 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2792 | 2792 | | |
2793 | 2793 | | |
2794 | 2794 | | |
2795 | | - | |
| 2795 | + | |
| 2796 | + | |
| 2797 | + | |
2796 | 2798 | | |
2797 | 2799 | | |
2798 | 2800 | | |
| |||
4961 | 4963 | | |
4962 | 4964 | | |
4963 | 4965 | | |
| 4966 | + | |
| 4967 | + | |
| 4968 | + | |
| 4969 | + | |
| 4970 | + | |
| 4971 | + | |
| 4972 | + | |
| 4973 | + | |
| 4974 | + | |
| 4975 | + | |
| 4976 | + | |
| 4977 | + | |
| 4978 | + | |
| 4979 | + | |
| 4980 | + | |
| 4981 | + | |
| 4982 | + | |
| 4983 | + | |
| 4984 | + | |
| 4985 | + | |
| 4986 | + | |
| 4987 | + | |
| 4988 | + | |
| 4989 | + | |
| 4990 | + | |
| 4991 | + | |
| 4992 | + | |
| 4993 | + | |
| 4994 | + | |
| 4995 | + | |
| 4996 | + | |
| 4997 | + | |
| 4998 | + | |
| 4999 | + | |
| 5000 | + | |
| 5001 | + | |
| 5002 | + | |
| 5003 | + | |
| 5004 | + | |
| 5005 | + | |
| 5006 | + | |
| 5007 | + | |
| 5008 | + | |
| 5009 | + | |
| 5010 | + | |
| 5011 | + | |
| 5012 | + | |
| 5013 | + | |
| 5014 | + | |
| 5015 | + | |
| 5016 | + | |
| 5017 | + | |
| 5018 | + | |
| 5019 | + | |
| 5020 | + | |
| 5021 | + | |
| 5022 | + | |
| 5023 | + | |
| 5024 | + | |
| 5025 | + | |
| 5026 | + | |
| 5027 | + | |
| 5028 | + | |
| 5029 | + | |
| 5030 | + | |
| 5031 | + | |
| 5032 | + | |
| 5033 | + | |
| 5034 | + | |
| 5035 | + | |
| 5036 | + | |
| 5037 | + | |
| 5038 | + | |
| 5039 | + | |
| 5040 | + | |
| 5041 | + | |
| 5042 | + | |
| 5043 | + | |
4964 | 5044 | | |
4965 | 5045 | | |
4966 | 5046 | | |
| |||
5092 | 5172 | | |
5093 | 5173 | | |
5094 | 5174 | | |
5095 | | - | |
| 5175 | + | |
5096 | 5176 | | |
5097 | 5177 | | |
5098 | 5178 | | |
| |||
0 commit comments