@@ -19,6 +19,7 @@ tests = testGroup "completions" [
1919 let te = TextEdit (Range (Position 5 7 ) (Position 5 24 )) " put"
2020 _ <- applyEdit doc te
2121
22+ _ <- waitForDiagnostics
2223 compls <- getCompletions doc (Position 5 9 )
2324 item <- getCompletionByLabel " putStrLn" compls
2425 liftIO $ do
@@ -35,6 +36,7 @@ tests = testGroup "completions" [
3536 let te = TextEdit (Range (Position 5 7 ) (Position 5 24 )) " put"
3637 _ <- applyEdit doc te
3738
39+ _ <- waitForDiagnostics
3840 compls <- getCompletions doc (Position 5 9 )
3941 item <- getCompletionByLabel " putStrLn" compls
4042 resolvedRes <- request SCompletionItemResolve item
@@ -56,6 +58,7 @@ tests = testGroup "completions" [
5658 let te = TextEdit (Range (Position 1 17 ) (Position 1 26 )) " Data.M"
5759 _ <- applyEdit doc te
5860
61+ _ <- waitForDiagnostics
5962 compls <- getCompletions doc (Position 1 23 )
6063 item <- getCompletionByLabel " Maybe" compls
6164 liftIO $ do
@@ -81,6 +84,7 @@ tests = testGroup "completions" [
8184 , testCase " completes with no prefix" $ runSession hlsCommand fullCaps " test/testdata/completion" $ do
8285 doc <- openDoc " Completion.hs" " haskell"
8386
87+ _ <- waitForDiagnostics
8488 compls <- getCompletions doc (Position 5 7 )
8589 liftIO $ assertBool " Expected completions" $ not $ null compls
8690
@@ -91,6 +95,7 @@ tests = testGroup "completions" [
9195 let te = TextEdit (Range (Position 5 0 ) (Position 5 2 )) " acc"
9296 _ <- applyEdit doc te
9397
98+ _ <- waitForDiagnostics
9499 compls <- getCompletions doc (Position 5 4 )
95100 item <- getCompletionByLabel " accessor" compls
96101 liftIO $ do
@@ -101,6 +106,7 @@ tests = testGroup "completions" [
101106
102107 let te = TextEdit (Range (Position 5 7 ) (Position 5 9 )) " id"
103108 _ <- applyEdit doc te
109+ _ <- waitForDiagnostics
104110 compls <- getCompletions doc (Position 5 9 )
105111 item <- getCompletionByLabel " id" compls
106112 liftIO $ do
@@ -111,6 +117,7 @@ tests = testGroup "completions" [
111117
112118 let te = TextEdit (Range (Position 5 7 ) (Position 5 24 )) " flip"
113119 _ <- applyEdit doc te
120+ _ <- waitForDiagnostics
114121 compls <- getCompletions doc (Position 5 11 )
115122 item <- getCompletionByLabel " flip" compls
116123 liftIO $
@@ -119,6 +126,7 @@ tests = testGroup "completions" [
119126 , testCase " maxCompletions" $ runSession hlsCommand fullCaps " test/testdata/completion" $ do
120127 doc <- openDoc " Completion.hs" " haskell"
121128
129+ _ <- waitForDiagnostics
122130 compls <- getCompletions doc (Position 5 7 )
123131 liftIO $ length compls @?= maxCompletions def
124132
@@ -128,6 +136,7 @@ tests = testGroup "completions" [
128136 let te = TextEdit (Range (Position 0 30 ) (Position 0 41 )) " A"
129137 _ <- applyEdit doc te
130138
139+ _ <- waitForDiagnostics
131140 compls <- getCompletions doc (Position 0 31 )
132141 item <- getCompletionByLabel " Alternative" compls
133142 liftIO $ do
@@ -141,6 +150,7 @@ tests = testGroup "completions" [
141150 let te = TextEdit (Range (Position 0 39 ) (Position 0 39 )) " , l"
142151 _ <- applyEdit doc te
143152
153+ _ <- waitForDiagnostics
144154 compls <- getCompletions doc (Position 0 42 )
145155 item <- getCompletionByLabel " liftA" compls
146156 liftIO $ do
@@ -159,6 +169,7 @@ snippetTests = testGroup "snippets" [
159169 let te = TextEdit (Range (Position 5 7 ) (Position 5 24 )) " Nothing"
160170 _ <- applyEdit doc te
161171
172+ _ <- waitForDiagnostics
162173 compls <- getCompletions doc (Position 5 14 )
163174 item <- getCompletionByLabel " Nothing" compls
164175 liftIO $ do
@@ -171,6 +182,7 @@ snippetTests = testGroup "snippets" [
171182 let te = TextEdit (Range (Position 5 7 ) (Position 5 24 )) " fold"
172183 _ <- applyEdit doc te
173184
185+ _ <- waitForDiagnostics
174186 compls <- getCompletions doc (Position 5 11 )
175187 item <- getCompletionByLabel " foldl" compls
176188 liftIO $ do
@@ -185,6 +197,7 @@ snippetTests = testGroup "snippets" [
185197 let te = TextEdit (Range (Position 5 7 ) (Position 5 24 )) " mapM"
186198 _ <- applyEdit doc te
187199
200+ _ <- waitForDiagnostics
188201 compls <- getCompletions doc (Position 5 11 )
189202 item <- getCompletionByLabel " mapM" compls
190203 liftIO $ do
@@ -199,6 +212,7 @@ snippetTests = testGroup "snippets" [
199212 let te = TextEdit (Range (Position 5 7 ) (Position 5 24 )) " even `filte"
200213 _ <- applyEdit doc te
201214
215+ _ <- waitForDiagnostics
202216 compls <- getCompletions doc (Position 5 18 )
203217 item <- getCompletionByLabel " filter" compls
204218 liftIO $ do
@@ -213,6 +227,7 @@ snippetTests = testGroup "snippets" [
213227 let te = TextEdit (Range (Position 5 7 ) (Position 5 24 )) " even `filte`"
214228 _ <- applyEdit doc te
215229
230+ _ <- waitForDiagnostics
216231 compls <- getCompletions doc (Position 5 18 )
217232 item <- getCompletionByLabel " filter" compls
218233 liftIO $ do
@@ -227,6 +242,7 @@ snippetTests = testGroup "snippets" [
227242 let te = TextEdit (Range (Position 5 7 ) (Position 5 24 )) " \"\" `Data.List.interspe"
228243 _ <- applyEdit doc te
229244
245+ _ <- waitForDiagnostics
230246 compls <- getCompletions doc (Position 5 29 )
231247 item <- getCompletionByLabel " intersperse" compls
232248 liftIO $ do
@@ -241,6 +257,7 @@ snippetTests = testGroup "snippets" [
241257 let te = TextEdit (Range (Position 5 7 ) (Position 5 24 )) " \"\" `Data.List.interspe`"
242258 _ <- applyEdit doc te
243259
260+ _ <- waitForDiagnostics
244261 compls <- getCompletions doc (Position 5 29 )
245262 item <- getCompletionByLabel " intersperse" compls
246263 liftIO $ do
@@ -268,6 +285,7 @@ snippetTests = testGroup "snippets" [
268285 let te = TextEdit (Range (Position 1 0 ) (Position 1 2 )) " MkF"
269286 _ <- applyEdit doc te
270287
288+ _ <- waitForDiagnostics
271289 compls <- getCompletions doc (Position 1 6 )
272290 item <- case find (\ c -> (c ^. label == " MkFoo" ) && maybe False (" MkFoo {" `T.isPrefixOf` ) (c ^. insertText)) compls of
273291 Just c -> pure c
@@ -281,6 +299,7 @@ snippetTests = testGroup "snippets" [
281299 let te = TextEdit (Range (Position 5 7 ) (Position 5 24 )) " fold"
282300 _ <- applyEdit doc te
283301
302+ _ <- waitForDiagnostics
284303 compls <- getCompletions doc (Position 5 11 )
285304 item <- getCompletionByLabel " foldl" compls
286305 liftIO $ do
@@ -306,6 +325,7 @@ contextTests = testGroup "contexts" [
306325 testCase " only provides type suggestions" $ runSession hlsCommand fullCaps " test/testdata/completion" $ do
307326 doc <- openDoc " Context.hs" " haskell"
308327
328+ _ <- waitForDiagnostics
309329 compls <- getCompletions doc (Position 2 17 )
310330 liftIO $ do
311331 compls `shouldContainCompl` " Integer"
@@ -314,6 +334,7 @@ contextTests = testGroup "contexts" [
314334 , testCase " only provides value suggestions" $ runSession hlsCommand fullCaps " test/testdata/completion" $ do
315335 doc <- openDoc " Context.hs" " haskell"
316336
337+ _ <- waitForDiagnostics
317338 compls <- getCompletions doc (Position 3 10 )
318339 liftIO $ do
319340 compls `shouldContainCompl` " abs"
@@ -322,6 +343,7 @@ contextTests = testGroup "contexts" [
322343 , testCase " completes qualified type suggestions" $ runSession hlsCommand fullCaps " test/testdata/completion" $ do
323344 doc <- openDoc " Context.hs" " haskell"
324345
346+ _ <- waitForDiagnostics
325347 compls <- getCompletions doc (Position 2 26 )
326348 liftIO $ do
327349 compls `shouldNotContainCompl` " forkOn"
0 commit comments