@@ -82,7 +82,7 @@ hlintTests = testGroup "hlint suggestions" [
8282 contents <- skipManyTill publishDiagnosticsNotification $ getDocumentEdit doc
8383 liftIO $ contents `elem` [" main = undefined\n foo = id\n " , " main = undefined\n foo x = x\n " ] @? " Command is applied"
8484
85- , testCase " changing configuration enables or disables hints " $ runSession hlsCommand fullCaps " test/testdata/hlint" $ do
85+ , testCase " changing configuration enables or disables hlint diagnostics " $ runSession hlsCommand fullCaps " test/testdata/hlint" $ do
8686 let config = def { hlintOn = True }
8787 sendNotification WorkspaceDidChangeConfiguration (DidChangeConfigurationParams (toJSON config))
8888
@@ -98,6 +98,31 @@ hlintTests = testGroup "hlint suggestions" [
9898
9999 liftIO $ Just " hlint" `notElem` map (^. L. source) diags' @? " There are no hlint diagnostics"
100100
101+ , testCase " changing document contents updates hlint diagnostics" $ runSession hlsCommand fullCaps " test/testdata/hlint" $ do
102+ doc <- openDoc " ApplyRefact2.hs" " haskell"
103+ diags <- waitForDiagnosticsSource " hlint"
104+
105+ liftIO $ length diags @?= 2 -- "Eta Reduce" and "Redundant Id"
106+
107+ let change = TextDocumentContentChangeEvent
108+ (Just (Range (Position 1 8 ) (Position 1 12 )))
109+ Nothing " x"
110+
111+ changeDoc doc [change]
112+
113+ diags' <- waitForDiagnostics
114+
115+ liftIO $ (not $ Just " hlint" `elem` map (^. L. source) diags') @? " There are no hlint diagnostics"
116+
117+ let change' = TextDocumentContentChangeEvent
118+ (Just (Range (Position 1 8 ) (Position 1 12 )))
119+ Nothing " id x"
120+
121+ changeDoc doc [change']
122+
123+ diags'' <- waitForDiagnosticsSource " hlint"
124+
125+ liftIO $ length diags'' @?= 2
101126 ]
102127
103128renameTests :: TestTree
0 commit comments