Skip to content

Commit 1931b72

Browse files
committed
Fixes pragma plugin offering incorrect code actions haskell#3673
1 parent a726296 commit 1931b72

File tree

1 file changed

+3
-1
lines changed
  • plugins/hls-pragmas-plugin/src/Ide/Plugin

1 file changed

+3
-1
lines changed

plugins/hls-pragmas-plugin/src/Ide/Plugin/Pragmas.hs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@ warningBlacklist = ["deferred-type-errors"]
137137
-- | Offer to add a missing Language Pragma to the top of a file.
138138
-- Pragmas are defined by a curated list of known pragmas, see 'possiblePragmas'.
139139
suggestAddPragma :: Maybe DynFlags -> Diagnostic -> [PragmaEdit]
140-
suggestAddPragma mDynflags Diagnostic {_message} = genPragma _message
140+
suggestAddPragma mDynflags Diagnostic {_message, _source}
141+
| _source == Just "typecheck" || _source == Just "parser" = genPragma _message
141142
where
142143
genPragma target =
143144
[("Add \"" <> r <> "\"", LangExt r) | r <- findPragma target, r `notElem` disabled]
@@ -149,6 +150,7 @@ suggestAddPragma mDynflags Diagnostic {_message} = genPragma _message
149150
-- When the module failed to parse, we don't have access to its
150151
-- dynFlags. In that case, simply don't disable any pragmas.
151152
[]
153+
suggestAddPragma _ _ = []
152154

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

0 commit comments

Comments
 (0)