diff --git a/test/functional/FunctionalCodeAction.hs b/test/functional/FunctionalCodeAction.hs index f07af9c72b5..0e34730fa53 100644 --- a/test/functional/FunctionalCodeAction.hs +++ b/test/functional/FunctionalCodeAction.hs @@ -98,6 +98,32 @@ hlintTests = testGroup "hlint suggestions" [ liftIO $ Just "hlint" `notElem` map (^. L.source) diags' @? "There are no hlint diagnostics" + , testCase "changing document contents updates hlint diagnostics" $ runSession hlsCommand fullCaps "test/testdata/hlint" $ do + doc <- openDoc "ApplyRefact2.hs" "haskell" + diags <- waitForDiagnosticsSource "hlint" + + liftIO $ length diags @?= 2 -- "Eta Reduce" and "Redundant Id" + + let change = TextDocumentContentChangeEvent + (Just (Range (Position 1 8) (Position 1 12))) + Nothing "x" + + changeDoc doc [change] + + diags' <- waitForDiagnostics + + liftIO $ (not $ Just "hlint" `elem` map (^. L.source) diags') @? "There are no hlint diagnostics" + + let change' = TextDocumentContentChangeEvent + (Just (Range (Position 1 8) (Position 1 12))) + Nothing "id x" + + changeDoc doc [change'] + + diags'' <- waitForDiagnosticsSource "hlint" + + liftIO $ length diags'' @?= 2 + , testCase "apply hints works with LambdaCase" $ runSession hlsCommand fullCaps "test/testdata/hlint" $ do doc <- openDoc "ApplyRefact1.hs" "haskell" diags <- waitForDiagnosticsSource "hlint"