Skip to content

Commit

Permalink
Fixes pragma plugin offering incorrect code actions haskell#3673
Browse files Browse the repository at this point in the history
  • Loading branch information
joyfulmantis committed Jun 26, 2023
1 parent a726296 commit 1931b72
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion plugins/hls-pragmas-plugin/src/Ide/Plugin/Pragmas.hs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ warningBlacklist = ["deferred-type-errors"]
-- | Offer to add a missing Language Pragma to the top of a file.
-- Pragmas are defined by a curated list of known pragmas, see 'possiblePragmas'.
suggestAddPragma :: Maybe DynFlags -> Diagnostic -> [PragmaEdit]
suggestAddPragma mDynflags Diagnostic {_message} = genPragma _message
suggestAddPragma mDynflags Diagnostic {_message, _source}
| _source == Just "typecheck" || _source == Just "parser" = genPragma _message
where
genPragma target =
[("Add \"" <> r <> "\"", LangExt r) | r <- findPragma target, r `notElem` disabled]
Expand All @@ -149,6 +150,7 @@ suggestAddPragma mDynflags Diagnostic {_message} = genPragma _message
-- When the module failed to parse, we don't have access to its
-- dynFlags. In that case, simply don't disable any pragmas.
[]
suggestAddPragma _ _ = []

-- | Find all Pragmas are an infix of the search term.
findPragma :: T.Text -> [T.Text]
Expand Down

0 comments on commit 1931b72

Please sign in to comment.