@@ -74,7 +74,7 @@ import Language.LSP.Types hiding
7474 SemanticTokensEdit (_start ),
7575 mkRange )
7676import Language.LSP.Types.Capabilities
77- import qualified Language.LSP.Types.Lens as Lens (label )
77+ import qualified Language.LSP.Types.Lens as Lens (label , insertText )
7878import qualified Language.LSP.Types.Lens as Lsp (diagnostics ,
7979 message ,
8080 params )
@@ -4781,11 +4781,8 @@ completionNoCommandTest name src pos wanted = testSession name $ do
47814781 docId <- createDoc " A.hs" " haskell" (T. unlines src)
47824782 _ <- waitForDiagnostics
47834783 compls <- getCompletions docId pos
4784- let wantedC = find ( \ case
4785- CompletionItem {_insertText = Just x} -> wanted `T.isPrefixOf` x
4786- _ -> False
4787- ) compls
4788- case wantedC of
4784+ let isPrefixOfInsertOrLabel ci = any (wanted `T.isPrefixOf` ) [fromMaybe " " (ci ^. Lens. insertText), ci ^. Lens. label]
4785+ case find isPrefixOfInsertOrLabel compls of
47894786 Nothing ->
47904787 liftIO $ assertFailure $ " Cannot find expected completion in: " <> show [_label | CompletionItem {_label} <- compls]
47914788 Just CompletionItem {.. } -> liftIO . assertBool (" Expected no command but got: " <> show _command) $ null _command
@@ -5042,6 +5039,19 @@ nonLocalCompletionTests =
50425039 " join"
50435040 [" {-# LANGUAGE NoImplicitPrelude #-}" ,
50445041 " module A where" , " import Control.Monad as M ()" , " import Control.Monad as N (join)" , " f = N.joi" ]
5042+ -- Failing test for https://github.com/haskell/haskell-language-server/issues/2824
5043+ , expectFailBecause " known broken #2824" $ completionNoCommandTest
5044+ " explicit qualified"
5045+ [" {-# LANGUAGE NoImplicitPrelude #-}" ,
5046+ " module A where" , " import qualified Control.Monad as M (j)" ]
5047+ (Position 2 38 )
5048+ " join"
5049+ , completionNoCommandTest
5050+ " explicit qualified post"
5051+ [" {-# LANGUAGE NoImplicitPrelude, ImportQualifiedPost #-}" ,
5052+ " module A where" , " import Control.Monad qualified as M (j)" ]
5053+ (Position 2 38 )
5054+ " join"
50455055 ]
50465056 , testGroup " Data constructor"
50475057 [ completionCommandTest
0 commit comments