@@ -642,23 +642,78 @@ 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
+ logMessage " item.InlineDescription"
652
+ logMessage ( item.InlineDescription |> serialize |> string)
653
+
654
+ logMessage " item.Properties"
655
+ logMessage ( item.Properties |> serialize |> string)
656
+
657
+ let! description = completionService.GetDescriptionAsync( doc, item, ct) |> Async.AwaitTask
658
+ logMessage " description.Text"
659
+ logMessage ( description.Text |> serialize |> string)
660
+ logMessage " description.TaggedParts"
661
+ logMessage ( description.TaggedParts |> serialize |> string)
662
+
663
+ let descriptionParts =
664
+ description.Text.Split( " \n " )
665
+ |> Seq.map ( fun s -> s.Trim())
666
+ |> List.ofSeq
667
+
668
+ let contextPosition =
669
+ item.Properties[ " ContextPosition" ]
670
+ |> int
671
+
672
+ logMessage ( sprintf " contextPosition=%d " contextPosition)
673
+
674
+ let contextBefore =
675
+ docText.GetSubText( TextSpan.FromBounds( contextPosition-10 , contextPosition))
676
+ |> string
677
+ logMessage ( sprintf " contextBefore=%s " contextBefore)
678
+
679
+ let contextAfter =
680
+ docText.GetSubText( TextSpan.FromBounds( contextPosition, contextPosition+ 10 ))
681
+ |> string
682
+ logMessage ( sprintf " contextAfter=%s " contextAfter)
683
+
684
+ let _descriptionMethodName , descriptionMethodDocString =
685
+ match descriptionParts with
686
+ | [] -> ( " " , " " )
687
+ | [ name] -> ( name, " " )
688
+ | name :: docRemainder -> ( name, docRemainder |> String.concat " \n " )
689
+
690
+ let displayText =
691
+ item.DisplayTextPrefix + item.DisplayText + item.DisplayTextSuffix
692
+
693
+ let documentation =
694
+ match descriptionMethodDocString with
695
+ | " " -> None
696
+ | docString -> Types.Documentation.Markup {
697
+ Kind = MarkupKind.PlainText
698
+ Value = docString
699
+ } |> Some
700
+
701
+ let baseCompletionItem = CompletionItem.Create( displayText)
702
+
703
+ return
704
+ { baseCompletionItem with
705
+ Kind = item.Tags |> Seq.head |> roslynTagToLspCompletion |> Some
706
+ SortText = item.SortText |> Option.ofObj
707
+ FilterText = item.FilterText |> Option.ofObj
708
+ InsertTextFormat = Some Types.InsertTextFormat.PlainText
709
+ Documentation = documentation
710
+ }
711
+ }
658
712
659
713
let completionItems =
660
714
completionResults.ItemsList
661
715
|> Seq.map makeLspCompletionItem
716
+ |> Seq.map Async.RunSynchronously
662
717
|> Array.ofSeq
663
718
664
719
let completionList = {
0 commit comments