@@ -33,7 +33,6 @@ import Test.Hls.Util
33
33
import Test.Tasty
34
34
import Test.Tasty.HUnit
35
35
36
-
37
36
tests :: TestTree
38
37
tests
39
38
= testGroup " completion"
@@ -61,6 +60,7 @@ completionTest :: HasCallStack => String -> [T.Text] -> Position -> [(T.Text, Co
61
60
completionTest name src pos expected = testSessionSingleFile name " A.hs" (T. unlines src) $ do
62
61
docId <- openDoc " A.hs" " haskell"
63
62
_ <- waitForDiagnostics
63
+
64
64
compls <- getAndResolveCompletions docId pos
65
65
let compls' = [ (_label, _kind, _insertText, _additionalTextEdits) | CompletionItem {.. } <- compls]
66
66
let emptyToMaybe x = if T. null x then Nothing else Just x
@@ -211,7 +211,38 @@ localCompletionTests = [
211
211
212
212
compls <- getCompletions doc (Position 0 15 )
213
213
liftIO $ filter (" AAA" `T.isPrefixOf` ) (mapMaybe _insertText compls) @?= [" AAAAA" ]
214
- pure ()
214
+ pure () ,
215
+ completionTest
216
+ " polymorphic record dot completion"
217
+ [ " {-# LANGUAGE OverloadedRecordDot #-}"
218
+ , " module A () where"
219
+ , " data Record = Record"
220
+ , " { field1 :: Int"
221
+ , " , field2 :: Int"
222
+ , " }"
223
+ , -- Without the following, this file doesn't trigger any diagnostics, so completionTest waits forever
224
+ " triggerDiag :: UnknownType"
225
+ , " foo record = record.f"
226
+ ]
227
+ (Position 7 21 )
228
+ [(" field1" , CompletionItemKind_Function , " field1" , True , False , Nothing )
229
+ ,(" field2" , CompletionItemKind_Function , " field2" , True , False , Nothing )
230
+ ],
231
+ completionTest
232
+ " qualified polymorphic record dot completion"
233
+ [ " {-# LANGUAGE OverloadedRecordDot #-}"
234
+ , " module A () where"
235
+ , " data Record = Record"
236
+ , " { field1 :: Int"
237
+ , " , field2 :: Int"
238
+ , " }"
239
+ , " someValue = undefined"
240
+ , " foo = A.someValue.f"
241
+ ]
242
+ (Position 7 19 )
243
+ [(" field1" , CompletionItemKind_Function , " field1" , True , False , Nothing )
244
+ ,(" field2" , CompletionItemKind_Function , " field2" , True , False , Nothing )
245
+ ]
215
246
]
216
247
217
248
nonLocalCompletionTests :: [TestTree ]
0 commit comments