@@ -82,7 +82,7 @@ hlintTests = testGroup "hlint suggestions" [
82
82
contents <- skipManyTill publishDiagnosticsNotification $ getDocumentEdit doc
83
83
liftIO $ contents `elem` [" main = undefined\n foo = id\n " , " main = undefined\n foo x = x\n " ] @? " Command is applied"
84
84
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
86
86
let config = def { hlintOn = True }
87
87
sendNotification WorkspaceDidChangeConfiguration (DidChangeConfigurationParams (toJSON config))
88
88
@@ -98,6 +98,31 @@ hlintTests = testGroup "hlint suggestions" [
98
98
99
99
liftIO $ Just " hlint" `notElem` map (^. L. source) diags' @? " There are no hlint diagnostics"
100
100
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
101
126
]
102
127
103
128
renameTests :: TestTree
0 commit comments