@@ -642,23 +642,56 @@ let setupServerHandlers options (lspClient: LspClient) =
642642 return ()
643643
644644 let! maybeCompletionResults =
645- completionService.GetCompletionsAsync( doc, posInText) |> Async.AwaitTask
645+ completionService.GetCompletionsAsync( doc, posInText, cancellationToken = ct ) |> Async.AwaitTask
646646
647647 match Option.ofObj maybeCompletionResults with
648648 | Some completionResults ->
649- let makeLspCompletionItem ( item : Microsoft.CodeAnalysis.Completion.CompletionItem ) =
650- let baseCompletionItem = CompletionItem.Create( item.DisplayText)
651-
652- { baseCompletionItem with
653- Kind = item.Tags |> Seq.head |> roslynTagToLspCompletion |> Some
654- SortText = item.SortText |> Option.ofObj
655- FilterText = item.FilterText |> Option.ofObj
656- InsertTextFormat = Some Types.InsertTextFormat.PlainText
657- }
649+ let makeLspCompletionItem ( item : Microsoft.CodeAnalysis.Completion.CompletionItem ) = async {
650+
651+ let! description = completionService.GetDescriptionAsync( doc, item, ct) |> Async.AwaitTask
652+ logMessage " description.Text"
653+ logMessage ( description.Text |> serialize |> string)
654+ logMessage " description.TaggedParts"
655+ logMessage ( description.TaggedParts |> serialize |> string)
656+
657+ let descriptionParts =
658+ description.Text.Split( " \n " )
659+ |> Seq.map ( fun s -> s.Trim())
660+ |> List.ofSeq
661+
662+ let _descriptionMethodName , descriptionMethodDocString =
663+ match descriptionParts with
664+ | [] -> ( " " , " " )
665+ | [ name] -> ( name, " " )
666+ | name :: docRemainder -> ( name, docRemainder |> String.concat " \n " )
667+
668+ let displayText =
669+ item.DisplayText
670+
671+ let documentation =
672+ match descriptionMethodDocString with
673+ | " " -> None
674+ | docString -> Types.Documentation.Markup {
675+ Kind = MarkupKind.PlainText
676+ Value = docString
677+ } |> Some
678+
679+ let baseCompletionItem = CompletionItem.Create( displayText)
680+
681+ return
682+ { baseCompletionItem with
683+ Kind = item.Tags |> Seq.head |> roslynTagToLspCompletion |> Some
684+ SortText = item.SortText |> Option.ofObj
685+ FilterText = item.FilterText |> Option.ofObj
686+ InsertTextFormat = Some Types.InsertTextFormat.PlainText
687+ Documentation = documentation
688+ }
689+ }
658690
659691 let completionItems =
660692 completionResults.ItemsList
661693 |> Seq.map makeLspCompletionItem
694+ |> Seq.map Async.RunSynchronously
662695 |> Array.ofSeq
663696
664697 let completionList = {
0 commit comments