From 1030d79afa15a2394d1498d2407276beba5d56cf Mon Sep 17 00:00:00 2001 From: Pepe Iborra Date: Sun, 24 Jan 2021 11:03:20 +0000 Subject: [PATCH 1/2] Reorder code actions to put remove redundant imports first --- ghcide/src/Development/IDE/Plugin/CodeAction.hs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ghcide/src/Development/IDE/Plugin/CodeAction.hs b/ghcide/src/Development/IDE/Plugin/CodeAction.hs index 8b3a8512b9..e2d5c29047 100644 --- a/ghcide/src/Development/IDE/Plugin/CodeAction.hs +++ b/ghcide/src/Development/IDE/Plugin/CodeAction.hs @@ -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 @@ -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 = From 93a912ef829b90dbd4b668a5b38169ecd858f9ba Mon Sep 17 00:00:00 2001 From: Pepe Iborra Date: Sun, 24 Jan 2021 12:26:20 +0000 Subject: [PATCH 2/2] hlint --- ghcide/src/Development/IDE/Plugin/CodeAction.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ghcide/src/Development/IDE/Plugin/CodeAction.hs b/ghcide/src/Development/IDE/Plugin/CodeAction.hs index e2d5c29047..ab668bb51f 100644 --- a/ghcide/src/Development/IDE/Plugin/CodeAction.hs +++ b/ghcide/src/Development/IDE/Plugin/CodeAction.hs @@ -122,7 +122,7 @@ codeAction lsp state (TextDocumentIdentifier uri) _range CodeActionContext{_diag <> actions <> actions' <> caRemoveInvalidExports parsedModule text diag xs uri - pure $ Right $ actions'' + pure $ Right actions'' mkCA :: T.Text -> [Diagnostic] -> WorkspaceEdit -> CAResult mkCA title diags edit =