Skip to content

Reorder code actions to put remove redundant imports first #1255

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 2 commits into from
Jan 24, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions ghcide/src/Development/IDE/Plugin/CodeAction.hs
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,7 @@ codeAction lsp state (TextDocumentIdentifier uri) _range CodeActionContext{_diag
[ mkCA title [x] edit
| x <- xs, (title, tedit) <- suggestAction exportsMap ideOptions parsedModule text x
, let edit = WorkspaceEdit (Just $ Map.singleton uri $ List tedit) Nothing
] <> caRemoveInvalidExports parsedModule text diag xs uri
<> caRemoveRedundantImports parsedModule text diag xs uri

]
actions' =
[mkCA title [x] edit
| x <- xs
Expand All @@ -120,7 +118,11 @@ codeAction lsp state (TextDocumentIdentifier uri) _range CodeActionContext{_diag
, let edit = either error id $
rewriteToEdit dynflags uri (annsA ps) graft
]
pure $ Right $ actions' <> actions
actions'' = caRemoveRedundantImports parsedModule text diag xs uri
<> actions
<> actions'
<> caRemoveInvalidExports parsedModule text diag xs uri
pure $ Right actions''

mkCA :: T.Text -> [Diagnostic] -> WorkspaceEdit -> CAResult
mkCA title diags edit =
Expand Down