async Task GetDescriptionAsync(RoslynCompletionSet completionSet, RoslynCompletion completion, CancellationToken cancellationToken)
            {
                var description = await completionSet.GetDescriptionAsync(completion, cancellationToken);

                if (description is null || description.TaggedParts.IsDefault || description.TaggedParts.Length == 0)
                {
                    InitializeDefaultDocumentation();
                }
        /// <summary>
        /// Gets the description or null if none
        /// </summary>
        /// <param name="completion">Completion</param>
        /// <param name="cancellationToken">Cancellation token</param>
        /// <returns></returns>
        public Task <CompletionDescription> GetDescriptionAsync(RoslynCompletion completion, CancellationToken cancellationToken = default)
        {
            if (completion == null)
            {
                throw new ArgumentNullException(nameof(completion));
            }

            var info = CompletionInfo.Create(textView.TextSnapshot);

            if (info == null)
            {
                return(Task.FromResult <CompletionDescription>(null));
            }

            return(completionService.GetDescriptionAsync(info.Value.Document, completion.CompletionItem, cancellationToken));
        }
        public void Commit(RoslynCompletion completion)
        {
            if (completion == null)
            {
                throw new ArgumentNullException(nameof(completion));
            }

            mruCompletionService.AddText(completion.DisplayText);

            var info = CompletionInfo.Create(ApplicableTo.TextBuffer.CurrentSnapshot);

            Debug.Assert(info != null);
            if (info == null)
            {
                return;
            }

            var change          = completionService.GetChangeAsync(info.Value.Document, completion.CompletionItem, commitCharacter: null).GetAwaiter().GetResult();
            var buffer          = ApplicableTo.TextBuffer;
            var currentSnapshot = buffer.CurrentSnapshot;

            using (var ed = buffer.CreateEdit()) {
                var textChange = change.TextChange;
                Debug.Assert(textChange.Span.End <= originalSnapshot.Length);
                if (textChange.Span.End > originalSnapshot.Length)
                {
                    return;
                }
                var span = new SnapshotSpan(originalSnapshot, textChange.Span.ToSpan()).TranslateTo(currentSnapshot, SpanTrackingMode.EdgeInclusive);
                if (!ed.Replace(span.Span, textChange.NewText))
                {
                    return;
                }
                ed.Apply();
            }
            if (change.NewPosition != null)
            {
                var snapshot = buffer.CurrentSnapshot;
                Debug.Assert(change.NewPosition.Value <= snapshot.Length);
                if (change.NewPosition.Value <= snapshot.Length)
                {
                    textView.Caret.MoveTo(new SnapshotPoint(snapshot, change.NewPosition.Value));
                    textView.Caret.EnsureVisible();
                }
            }
        }
 public AsyncToolTipContent(CompletionToolTipProvider owner, RoslynCompletionSet completionSet, RoslynCompletion completion, ICompletionSession session, ITaggedTextElementProviderService taggedTextElementProviderService, bool colorize)
 {
     this.owner = owner;
     Session    = session;
     cancellationTokenSource = new CancellationTokenSource();
     this.taggedTextElementProviderService = taggedTextElementProviderService;
     this.colorize      = colorize;
     Session.Dismissed += Session_Dismissed;
     Unloaded          += AsyncToolTipContent_Unloaded;
     GetDescriptionAsync(completionSet, completion, cancellationTokenSource.Token)
     .ContinueWith(t => {
         var ex = t.Exception;
         Dispose();
     }, CancellationToken.None, TaskContinuationOptions.None, TaskScheduler.FromCurrentSynchronizationContext());
 }