Esempio n. 1
0
        private void HandleCompletionSessionCommit(object sender, EventArgs e)
        {
            CompletionSet completionSet = ((ICompletionSession)sender).SelectedCompletionSet;

            if (completionSet == null)
            {
                return;
            }

            SnapshotSpan span  = completionSet.ApplicableTo.GetSpan(completionSet.ApplicableTo.TextBuffer.CurrentSnapshot);
            int          caret = span.Span.Start;

            if (PackageCompletionSource.TryHealOrAdvanceAttributeSelection(span.Snapshot, ref caret, out Span targetSpan, out string replacementText, out bool isHealingRequired))
            {
                if (isHealingRequired)
                {
                    ITextSnapshot newSnapshot = span.Snapshot.TextBuffer.Replace(targetSpan, replacementText);
                    TextView.Caret.MoveTo(new SnapshotPoint(newSnapshot, caret));
                }
                else
                {
                    TextView.Caret.MoveTo(new SnapshotPoint(span.Snapshot, caret));
                }

                Broker.TriggerCompletion(TextView);
            }
        }
        public ICompletionSource TryCreateCompletionSource(ITextBuffer textBuffer)
        {
            string text   = textBuffer.CurrentSnapshot.GetText();
            bool   isCore = text.IndexOf("Microsoft.Net.Sdk", StringComparison.OrdinalIgnoreCase) > -1;

            if (isCore)
            {
                return(PackageCompletionSource.GetOrAddCompletionSource(textBuffer, _completionBroker, _classifier, _searchManager));
            }

            return(null);
        }