Skip to content

Filter code actions by prefix, not equality #3071

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

Merged
merged 1 commit into from
Aug 31, 2021

Conversation

michaelpj
Copy link
Contributor

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.

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.
@yyoncho yyoncho merged commit 2e19005 into emacs-lsp:master Aug 31, 2021
@yyoncho
Copy link
Member

yyoncho commented Aug 31, 2021

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants