Skip to content

Prefer extending import code actions#4851

Merged
fendor merged 2 commits into
haskell:masterfrom
vherrmann:prioritize-import-extensions
Feb 24, 2026
Merged

Prefer extending import code actions#4851
fendor merged 2 commits into
haskell:masterfrom
vherrmann:prioritize-import-extensions

Conversation

@vherrmann

Copy link
Copy Markdown
Contributor

Fixes #4750.

Before this PR:

screen_2026-02-23_22-32-49

After this PR:

screen_2026-02-23_22-30-57

The PR achieves this by setting isPreferred for the corresponding code actions. I do not find this a completely satisfactory solutions, since ideally we should order the code actions according to a prioritization ("Add … to the import list …" should imo appear before more generic import list changes which should appear before "Replace with …" which should appear before "Define …").
On the other hand the LSP Spec afaik does not specify that clients should show the code actions according to the order given by the lsp server (And at least my emacs config does not seem to care about the servers order, in fact it does not even care about the "isPreferred" setting).

@vherrmann

Copy link
Copy Markdown
Contributor Author

Btw: the definition toCodeAction in ./plugins/hls-refactor-plugin/src/Development/IDE/Plugin/CodeAction/Args.hs is some very nice code. I guess one could achieve something similar with a reader monad (stack), but I still find the code kinda mind-blowing.

@fendor fendor left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you for your contribution!

@fendor fendor enabled auto-merge (squash) February 24, 2026 19:23
@fendor fendor merged commit b3b71b7 into haskell:master Feb 24, 2026
40 checks passed
@vherrmann vherrmann deleted the prioritize-import-extensions branch February 24, 2026 21:46
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.

Put QuickFix "Add ... to import list of ..." first

2 participants