private VSCompletion GetVSCompletion(CompletionItem item, string displayText = null)
        {
            if (!CompletionItemMap.TryGetValue(item, out var value))
            {
                value = new CustomCommitCompletion(CompletionPresenterSession, item);
                CompletionItemMap.Add(item, value);
            }

            value.DisplayText = displayText ?? item.DisplayText;

            return(value);
        }
Exemple #2
0
            public CancellableContentControl(ToolTipProvider toolTipProvider, CustomCommitCompletion item)
            {
                Debug.Assert(_foregroundObject.IsForeground());
                _toolTipProvider = toolTipProvider;

                // Set our content to be "..." initially.
                this.Content = toolTipProvider._defaultTextBlock;

                // Kick off the task to produce the new content.  When it completes, call back on
                // the UI thread to update the display.
                var scheduler = TaskScheduler.FromCurrentSynchronizationContext();

                item.GetDescriptionAsync(_cancellationTokenSource.Token)
                .ContinueWith(ProcessDescription, _cancellationTokenSource.Token,
                              TaskContinuationOptions.OnlyOnRanToCompletion, scheduler);

                // If we get unloaded (i.e. the user scrolls down in the completion list and VS
                // dismisses the existing tooltip), then cancel the work we're doing
                this.Unloaded += (s, e) => _cancellationTokenSource.Cancel();
            }