@@ -83,6 +83,36 @@ hlintTests = testGroup "hlint suggestions" [
83
83
contents <- skipManyTill anyMessage $ getDocumentEdit doc
84
84
liftIO $ contents @?= " main = undefined\n foo = id\n "
85
85
86
+ , testCase " changing configuration enables or disables hlint diagnostics" $ runHlintSession " " $ do
87
+ let config = def { hlintOn = True }
88
+ sendNotification WorkspaceDidChangeConfiguration (DidChangeConfigurationParams (toJSON config))
89
+
90
+ doc <- openDoc " ApplyRefact2.hs" " haskell"
91
+ testHlintDiagnostics doc
92
+
93
+ let config' = def { hlintOn = False }
94
+ sendNotification WorkspaceDidChangeConfiguration (DidChangeConfigurationParams (toJSON config'))
95
+
96
+ diags' <- waitForDiagnosticsFrom doc
97
+
98
+ liftIO $ noHlintDiagnostics diags'
99
+
100
+ , testCase " changing document contents updates hlint diagnostics" $ runHlintSession " " $ do
101
+ doc <- openDoc " ApplyRefact2.hs" " haskell"
102
+ testHlintDiagnostics doc
103
+
104
+ let change = TextDocumentContentChangeEvent
105
+ (Just (Range (Position 1 8 ) (Position 1 12 )))
106
+ Nothing " x"
107
+ changeDoc doc [change]
108
+ expectNoMoreDiagnostics 3 doc " hlint"
109
+
110
+ let change' = TextDocumentContentChangeEvent
111
+ (Just (Range (Position 1 8 ) (Position 1 12 )))
112
+ Nothing " id x"
113
+ changeDoc doc [change']
114
+ testHlintDiagnostics doc
115
+
86
116
, knownBrokenForGhcVersions [GHC88 , GHC86 ] " hlint doesn't take in account cpp flag as ghc -D argument" $
87
117
testCase " hlint diagnostics works with CPP via ghc -XCPP argument (#554)" $ runHlintSession " cpp" $ do
88
118
doc <- openDoc " ApplyRefact3.hs" " haskell"
0 commit comments