@@ -642,23 +642,56 @@ let setupServerHandlers options (lspClient: LspClient) =
642
642
return ()
643
643
644
644
let! maybeCompletionResults =
645
- completionService.GetCompletionsAsync( doc, posInText) |> Async.AwaitTask
645
+ completionService.GetCompletionsAsync( doc, posInText, cancellationToken = ct ) |> Async.AwaitTask
646
646
647
647
match Option.ofObj maybeCompletionResults with
648
648
| 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
+ }
658
690
659
691
let completionItems =
660
692
completionResults.ItemsList
661
693
|> Seq.map makeLspCompletionItem
694
+ |> Seq.map Async.RunSynchronously
662
695
|> Array.ofSeq
663
696
664
697
let completionList = {
0 commit comments