public void PresentItems(
            ITrackingSpan triggerSpan,
            IList <CompletionItem> completionItems,
            CompletionItem selectedItem,
            CompletionItem suggestionModeItem,
            bool suggestionMode,
            bool isSoftSelected,
            ImmutableArray <CompletionItemFilter> completionItemFilters,
            string filterText)
        {
            AssertIsForeground();

            // check if this update is still relevant
            if (_textView.IsClosed || _isDismissed)
            {
                return;
            }

            if (triggerSpan != null)
            {
                _completionSet.SetTrackingSpan(triggerSpan);
            }

            _ignoreSelectionStatusChangedEvent = true;
            try
            {
                _completionSet.SetCompletionItems(
                    completionItems, selectedItem, suggestionModeItem, suggestionMode,
                    isSoftSelected, completionItemFilters, filterText);
            }
            finally
            {
                _ignoreSelectionStatusChangedEvent = false;
            }

            if (_editorSessionOpt == null)
            {
                // We're tracking the caret.  Don't have the editor do it.
                // Map the span instead of a point to avoid affinity problems.
                _editorSessionOpt = _completionBroker.CreateCompletionSession(
                    _textView,
                    triggerSpan.GetStartTrackingPoint(PointTrackingMode.Negative),
                    trackCaret: false);

                _editorSessionOpt.Dismissed += (s, e) => OnEditorSessionDismissed();

                // So here's the deal.  We cannot create the editor session and give it the right
                // items (even though we know what they are).  Instead, the session will call
                // back into the ICompletionSourceProvider (which is us) to get those values. It
                // will pass itself along with the calls back into ICompletionSourceProvider.
                // So, in order to make that connection work, we add properties to the session
                // so that we can call back into ourselves, get the items and add it to the
                // session.
                _editorSessionOpt.Properties.AddProperty(Key, this);
                _editorSessionOpt.Start();
            }

            // Call so that the editor will refresh the completion text to embolden.
            _editorSessionOpt?.Match();
        }
예제 #2
0
 void Refilter()
 {
     if (!session.IsDismissed)
     {
         session.Filter();
         session.Match();
         // Filter() could've scrolled the selected item out of view (less items are shown but
         // it keeps the old viewport Y offset), and Match() could've selected the same item again
         // (i.e., no CurrentCompletionChanged event) which could result in the item being out of
         // view. Fix that by always making sure it's visible after Filter() + Match().
         UpdateSelectedItem();
     }
 }
        public static bool DoCallMatch(IntellisenseController completionTarget)
        {
            Contract.Requires <ArgumentNullException>(completionTarget != null, "completionTarget");

#if true
            return(false);
#else
            bool flag2 = false;
            ICompletionSession session = completionTarget.CompletionSession;
            if (session != null)
            {
                ITextSnapshot snapshot = session.TextView.TextSnapshot;
                string        text     = snapshot.GetText(completionTarget.CompletionInfo.ApplicableTo.GetSpan(snapshot));
                if (string.IsNullOrEmpty(text))
                {
                    return(false);
                }

                session.Match();
                CompletionSet set1  = null;
                CompletionSet set2  = null;
                CompletionSet set3  = null;
                CompletionSet set4  = null;
                bool          flag3 = false;
                bool          flag4 = false;
                foreach (CompletionSet set in session.CompletionSets.Where(i => i != null && i.SelectionStatus != null && i.SelectionStatus.Completion != null))
                {
                    flag2 = true;
                    bool isAllTab = false;
                    if (isAllTab)
                    {
                        set3  = set;
                        flag3 = string.Equals(text, set.SelectionStatus.Completion.DisplayText, StringComparison.CurrentCultureIgnoreCase);
                    }
                    else
                    {
                        set4  = set;
                        flag4 = string.Equals(text, set.SelectionStatus.Completion.DisplayText, StringComparison.CurrentCultureIgnoreCase);
                    }
                }

                if (flag3 && !flag4)
                {
                    set1 = set3;
                }
                else if (set2 != null)
                {
                    if (set2 != set3 && set4 == null)
                    {
                        set1 = set3;
                    }
                }
                else if (set4 != null)
                {
                    set1 = set4;
                }
                else
                {
                    set1 = set3;
                }

                if (set1 != null)
                {
                    session.SelectedCompletionSet = set1;
                }
            }

            return(flag2);
#endif
        }