Skip to content

Commit 2e19005

Browse files
authored
Filter code actions by prefix, not equality (#3071)
It's quite unclear in the spec, but the idea seems to generally be to filter code actions by their kinds *hierarchically*, so if the user asks for `refactor` actions, the server can return `refactor.inline` actions. This is usually what you want: for example, HLS has a variety of import-fixing actions which use sub-kinds of `quickfix.import`. These can be requested by just asking for the kind `quickfix.import`, which is very nice. However, in `lsp-mode` we then filter these down to those that match *exactly*. I think we should also do a prefix match. (My end goal is to be able to do `(lsp-make-interactive-code-action haskell-fix-imports "quickfix.import")` and have it actually select all the import-fixing actions and let the user pick one!) I don't think this will affect any existing users much. Since it currently doesn't work if you pass a kind expecting actions with sub-kinds, presumably current users are only passing maximally-specific kinds, and won't see any different behaviour.
1 parent c1997dc commit 2e19005

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lsp-mode.el

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5409,7 +5409,7 @@ It will filter by KIND if non nil."
54095409
"Execute code action by COMMAND-KIND."
54105410
(if-let ((action (->> (lsp-get-or-calculate-code-actions command-kind)
54115411
(-filter (-lambda ((&CodeAction :kind?))
5412-
(and kind? (equal command-kind kind?))))
5412+
(and kind? (s-prefix? command-kind kind?))))
54135413
lsp--select-action)))
54145414
(lsp-execute-code-action action)
54155415
(signal 'lsp-no-code-actions '(command-kind))))

0 commit comments

Comments
 (0)