@@ -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 )
@@ -4819,11 +4819,8 @@ completionNoCommandTest name src pos wanted = testSession name $ do
48194819 docId <- createDoc " A.hs" " haskell" (T. unlines src)
48204820 _ <- waitForDiagnostics
48214821 compls <- getCompletions docId pos
4822- let wantedC = find ( \ case
4823- CompletionItem {_insertText = Just x} -> wanted `T.isPrefixOf` x
4824- _ -> False
4825- ) compls
4826- case wantedC of
4822+ let isPrefixOfInsertOrLabel ci = any (wanted `T.isPrefixOf` ) [fromMaybe " " (ci ^. Lens. insertText), ci ^. Lens. label]
4823+ case find isPrefixOfInsertOrLabel compls of
48274824 Nothing ->
48284825 liftIO $ assertFailure $ " Cannot find expected completion in: " <> show [_label | CompletionItem {_label} <- compls]
48294826 Just CompletionItem {.. } -> liftIO . assertBool (" Expected no command but got: " <> show _command) $ null _command
@@ -5080,6 +5077,19 @@ nonLocalCompletionTests =
50805077 " join"
50815078 [" {-# LANGUAGE NoImplicitPrelude #-}" ,
50825079 " module A where" , " import Control.Monad as M ()" , " import Control.Monad as N (join)" , " f = N.joi" ]
5080+ -- Failing test for https://github.com/haskell/haskell-language-server/issues/2824
5081+ , expectFailBecause " known broken #2824" $ completionNoCommandTest
5082+ " explicit qualified"
5083+ [" {-# LANGUAGE NoImplicitPrelude #-}" ,
5084+ " module A where" , " import qualified Control.Monad as M (j)" ]
5085+ (Position 2 38 )
5086+ " join"
5087+ , completionNoCommandTest
5088+ " explicit qualified post"
5089+ [" {-# LANGUAGE NoImplicitPrelude, ImportQualifiedPost #-}" ,
5090+ " module A where" , " import Control.Monad qualified as M (j)" ]
5091+ (Position 2 38 )
5092+ " join"
50835093 ]
50845094 , testGroup " Data constructor"
50855095 [ completionCommandTest
0 commit comments