Skip to content

Commit d73aaa6

Browse files
committed
Hlint: CodeAction with isPreferred
> A refactoring should be marked preferred if it is the most reasonable choice of actions to take. For hlint it is the likeliest choice to apply the fix. Ignore the rule for the complete module is preferred less.
1 parent 6dcc0ee commit d73aaa6

File tree

1 file changed

+5
-5
lines changed
  • plugins/hls-hlint-plugin/src/Ide/Plugin

1 file changed

+5
-5
lines changed

plugins/hls-hlint-plugin/src/Ide/Plugin/Hlint.hs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -450,19 +450,19 @@ diagnosticToCodeActions dynFlags fileContents pluginId documentId diagnostic
450450
, let applyHintTitle = "Apply hint \"" <> hint <> "\""
451451
applyHintArguments = [toJSON (AOP (documentId ^. LSP.uri) start hint)]
452452
applyHintCommand = mkLspCommand pluginId "applyOne" applyHintTitle (Just applyHintArguments) ->
453-
Just (mkCodeAction applyHintTitle diagnostic Nothing (Just applyHintCommand))
453+
Just (mkCodeAction applyHintTitle diagnostic Nothing (Just applyHintCommand) True)
454454
| otherwise -> Nothing
455-
, Just (mkCodeAction suppressHintTitle diagnostic (Just suppressHintWorkspaceEdit) Nothing)
455+
, Just (mkCodeAction suppressHintTitle diagnostic (Just suppressHintWorkspaceEdit) Nothing False)
456456
]
457457
| otherwise = []
458458

459-
mkCodeAction :: T.Text -> LSP.Diagnostic -> Maybe LSP.WorkspaceEdit -> Maybe LSP.Command -> LSP.CodeAction
460-
mkCodeAction title diagnostic workspaceEdit command =
459+
mkCodeAction :: T.Text -> LSP.Diagnostic -> Maybe LSP.WorkspaceEdit -> Maybe LSP.Command -> Bool -> LSP.CodeAction
460+
mkCodeAction title diagnostic workspaceEdit command isPreferred =
461461
LSP.CodeAction
462462
{ _title = title
463463
, _kind = Just LSP.CodeActionQuickFix
464464
, _diagnostics = Just (LSP.List [diagnostic])
465-
, _isPreferred = Nothing
465+
, _isPreferred = Just isPreferred
466466
, _disabled = Nothing
467467
, _edit = workspaceEdit
468468
, _command = command

0 commit comments

Comments
 (0)