Skip to content

Commit 15c070c

Browse files
authored
Reorder code actions to put remove redundant imports first (#1255)
* Reorder code actions to put remove redundant imports first * hlint
1 parent aa802ce commit 15c070c

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

ghcide/src/Development/IDE/Plugin/CodeAction.hs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,7 @@ codeAction lsp state (TextDocumentIdentifier uri) _range CodeActionContext{_diag
108108
[ mkCA title [x] edit
109109
| x <- xs, (title, tedit) <- suggestAction exportsMap ideOptions parsedModule text x
110110
, let edit = WorkspaceEdit (Just $ Map.singleton uri $ List tedit) Nothing
111-
] <> caRemoveInvalidExports parsedModule text diag xs uri
112-
<> caRemoveRedundantImports parsedModule text diag xs uri
113-
111+
]
114112
actions' =
115113
[mkCA title [x] edit
116114
| x <- xs
@@ -120,7 +118,11 @@ codeAction lsp state (TextDocumentIdentifier uri) _range CodeActionContext{_diag
120118
, let edit = either error id $
121119
rewriteToEdit dynflags uri (annsA ps) graft
122120
]
123-
pure $ Right $ actions' <> actions
121+
actions'' = caRemoveRedundantImports parsedModule text diag xs uri
122+
<> actions
123+
<> actions'
124+
<> caRemoveInvalidExports parsedModule text diag xs uri
125+
pure $ Right actions''
124126

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

0 commit comments

Comments
 (0)