@@ -5562,12 +5562,25 @@ bootTests = testGroup "boot"
55625562 -- Dirty the cache
55635563 liftIO $ runInDir dir $ do
55645564 cDoc <- createDoc cPath " haskell" cSource
5565- _ <- getHover cDoc $ Position 4 3
5566- ~ () <- skipManyTill anyMessage $ satisfyMaybe $ \ case
5567- FromServerMess (SCustomMethod " ghcide/reference/ready" ) (NotMess NotificationMessage {_params = fp}) -> do
5568- A. Success fp' <- pure $ fromJSON fp
5569- if equalFilePath fp' cPath then pure () else Nothing
5570- _ -> Nothing
5565+ -- We send a hover request then wait for either the hover response or
5566+ -- `ghcide/reference/ready` notification.
5567+ -- Once we receive one of the above, we wait for the other that we
5568+ -- haven't received yet.
5569+ -- If we don't wait for the `ready` notification it is possible
5570+ -- that the `getDefinitions` request/response in the outer ghcide
5571+ -- session will find no definitions.
5572+ let hoverParams = HoverParams cDoc (Position 4 3 ) Nothing
5573+ hoverRequestId <- sendRequest STextDocumentHover hoverParams
5574+ let parseReadyMessage = satisfy $ \ case
5575+ FromServerMess (SCustomMethod " ghcide/reference/ready" ) (NotMess NotificationMessage {_params = params})
5576+ | A. Success fp <- fromJSON params -> equalFilePath fp cPath
5577+ _ -> False
5578+ let parseHoverResponse = responseForId STextDocumentHover hoverRequestId
5579+ hoverResponseOrReadyMessage <- skipManyTill anyMessage ((Left <$> parseHoverResponse) <|> (Right <$> parseReadyMessage))
5580+ _ <- skipManyTill anyMessage $
5581+ case hoverResponseOrReadyMessage of
5582+ Left _ -> void parseReadyMessage
5583+ Right _ -> void parseHoverResponse
55715584 closeDoc cDoc
55725585 cdoc <- createDoc cPath " haskell" cSource
55735586 locs <- getDefinitions cdoc (Position 7 4 )
0 commit comments