@@ -250,6 +250,67 @@ spec = describe "completions" $ do
250
250
item ^. insertTextFormat `shouldBe` Just Snippet
251
251
item ^. insertText `shouldBe` Just " mapM ${1:a -> m b} ${2:t a}"
252
252
253
+ it " work for infix functions" $ runSession hieCommand fullCaps " test/testdata/completion" $ do
254
+ doc <- openDoc " Completion.hs" " haskell"
255
+ _ <- skipManyTill loggingNotification (count 2 noDiagnostics)
256
+
257
+ let te = TextEdit (Range (Position 5 7 ) (Position 5 24 )) " even `filte"
258
+ _ <- applyEdit doc te
259
+
260
+ compls <- getCompletions doc (Position 5 17 )
261
+ let item = head $ filter ((== " filter" ) . (^. label)) compls
262
+ liftIO $ do
263
+ item ^. label `shouldBe` " filter"
264
+ item ^. kind `shouldBe` Just CiFunction
265
+ item ^. insertTextFormat `shouldBe` Just Snippet
266
+ item ^. insertText `shouldBe` Just " `filter`"
267
+
268
+ it " work for infix functions in backticks" $ runSession hieCommand fullCaps " test/testdata/completion" $ do
269
+ doc <- openDoc " Completion.hs" " haskell"
270
+ _ <- skipManyTill loggingNotification (count 2 noDiagnostics)
271
+
272
+ let te = TextEdit (Range (Position 5 7 ) (Position 5 24 )) " even `filte`"
273
+ _ <- applyEdit doc te
274
+
275
+ compls <- getCompletions doc (Position 5 17 )
276
+ let item = head $ filter ((== " filter" ) . (^. label)) compls
277
+ liftIO $ do
278
+ item ^. label `shouldBe` " filter"
279
+ item ^. kind `shouldBe` Just CiFunction
280
+ item ^. insertTextFormat `shouldBe` Just Snippet
281
+ item ^. insertText `shouldBe` Just " `filter`"
282
+
283
+ it " work for qualified infix functions" $ runSession hieCommand fullCaps " test/testdata/completion" $ do
284
+ doc <- openDoc " Completion.hs" " haskell"
285
+ _ <- skipManyTill loggingNotification (count 2 noDiagnostics)
286
+
287
+ let te = TextEdit (Range (Position 5 7 ) (Position 5 24 )) " \"\" `Data.List.interspe"
288
+ _ <- applyEdit doc te
289
+
290
+ compls <- getCompletions doc (Position 5 34 )
291
+ let item = head $ filter ((== " intersperse" ) . (^. label)) compls
292
+ liftIO $ do
293
+ item ^. label `shouldBe` " intersperse"
294
+ item ^. kind `shouldBe` Just CiFunction
295
+ item ^. insertTextFormat `shouldBe` Just Snippet
296
+ item ^. insertText `shouldBe` Just " `Data.List.intersperse`"
297
+
298
+ it " work for qualified infix functions in backticks" $ runSession hieCommand fullCaps " test/testdata/completion" $ do
299
+ doc <- openDoc " Completion.hs" " haskell"
300
+ _ <- skipManyTill loggingNotification (count 2 noDiagnostics)
301
+
302
+ let te = TextEdit (Range (Position 5 7 ) (Position 5 24 )) " \"\" `Data.List.interspe`"
303
+ _ <- applyEdit doc te
304
+
305
+
306
+ compls <- getCompletions doc (Position 5 34 )
307
+ let item = head $ filter ((== " intersperse" ) . (^. label)) compls
308
+ liftIO $ do
309
+ item ^. label `shouldBe` " intersperse"
310
+ item ^. kind `shouldBe` Just CiFunction
311
+ item ^. insertTextFormat `shouldBe` Just Snippet
312
+ item ^. insertText `shouldBe` Just " `Data.List.intersperse`"
313
+
253
314
it " respects lsp configuration" $ runSession hieCommand fullCaps " test/testdata/completion" $ do
254
315
doc <- openDoc " Completion.hs" " haskell"
255
316
_ <- skipManyTill loggingNotification (count 2 noDiagnostics)
0 commit comments