public static bool IsSet(ICompletionSession session)
        {
            PlainTextCompletionContext context = null;

            return(session.Properties.TryGetProperty(Key, out context) &&
                   context != null);
        }
Example #2
0
        private bool TriggerCompletion()
        {
            if (session != null)
            {
                session.Dismiss();
            }
            PrepareTriggerPoint();
            // since we might have modified the
            // buffer, check if that didn't kick another session
            if (AnySessionsActive())
            {
                return(false);
            }

            var caretPoint = textView.Caret.Position.BufferPosition;
            var snapshot   = caretPoint.Snapshot;

            var triggerPoint = snapshot.CreateTrackingPoint(
                caretPoint,
                PointTrackingMode.Negative);

            session = provider.CompletionBroker.CreateCompletionSession(
                this.textView, triggerPoint, false);
            if (session != null)
            {
                session.Dismissed += this.OnSessionDismissed;
                PlainTextCompletionContext.Add(session);
                session.Start();
                return(true);
            }
            return(false);
        }
        public void AugmentCompletionSession(ICompletionSession session, IList <CompletionSet> completionSets)
        {
            if (!settings.TextCompletionEnabled)
            {
                return;
            }
            if (session.TextView.TextBuffer != this.theBuffer)
            {
                return;
            }
            if (!PlainTextCompletionContext.IsSet(session))
            {
                return;
            }
            var snapshot     = theBuffer.CurrentSnapshot;
            var triggerPoint = session.GetTriggerPoint(snapshot);

            if (!triggerPoint.HasValue)
            {
                return;
            }

            var applicableToSpan = GetApplicableToSpan(triggerPoint.Value);

            var then = this.bufferStatsOnCompletion;
            var now  = new BufferStats(snapshot);

            if (currentCompletions == null || now.SignificantThan(then))
            {
                this.currentCompletions      = BuildCompletionsList();
                this.bufferStatsOnCompletion = now;
            }
            var set = new CompletionSet(
                moniker: "plainText",
                displayName: "Text",
                applicableTo: applicableToSpan,
                completions: currentCompletions,
                completionBuilders: null
                );

            completionSets.Add(set);
        }