diff --git a/src/Haskell/Ide/Engine/Plugin/HsImport.hs b/src/Haskell/Ide/Engine/Plugin/HsImport.hs index 0afb30840..434ef8daf 100644 --- a/src/Haskell/Ide/Engine/Plugin/HsImport.hs +++ b/src/Haskell/Ide/Engine/Plugin/HsImport.hs @@ -105,8 +105,9 @@ codeActionProvider plId docId _ _ context = do extractImportableTerm :: T.Text -> Maybe T.Text extractImportableTerm dirtyMsg = T.strip <$> asum - [T.stripPrefix "Variable not in scope: " msg, - T.init <$> T.stripPrefix "Not in scope: type constructor or class ‘" msg] + [ T.stripPrefix "Variable not in scope: " msg + , T.init <$> T.stripPrefix "Not in scope: type constructor or class ‘" msg + , T.stripPrefix "Data constructor not in scope: " msg] where msg = head -- Get rid of the rename suggestion parts $ T.splitOn "Perhaps you meant " diff --git a/test/unit/CodeActionsSpec.hs b/test/unit/CodeActionsSpec.hs index dac10793e..4bf547aa4 100644 --- a/test/unit/CodeActionsSpec.hs +++ b/test/unit/CodeActionsSpec.hs @@ -25,6 +25,9 @@ spec = do it "pick up when" $ let msg = "Variable not in scope: when :: Bool -> IO () -> t" in extractImportableTerm msg `shouldBe` Just "when :: Bool -> IO () -> t" + it "pick up data constructors" $ + let msg = "Data constructor not in scope: ExitFailure :: Integer -> t" + in extractImportableTerm msg `shouldBe` Just "ExitFailure :: Integer -> t" describe "rename code actions" $ do it "pick up variable not in scope perhaps you meant" $