Exemplo n.º 1
0
        /// <summary>
        /// Send the command to the current session head
        /// </summary>
        internal bool SendCommand(IntellisenseKeyboardCommand command)
        {
            // Don't send the command if the active completion set is not the word completion
            // set
            if (_wordCompletionSet != _completionSession.SelectedCompletionSet)
            {
                return(false);
            }

            var commandTarget = _intellisenseSessionStack as IIntellisenseCommandTarget;

            if (commandTarget == null)
            {
                return(false);
            }

            // Send the command
            if (!commandTarget.ExecuteKeyboardCommand(command))
            {
                return(false);
            }

            // Command succeeded so there is a new selection.  Put the new selection into the
            // ITextView to replace the current selection
            var wordSpan = TrackingSpanUtil.GetSpan(_textView.TextSnapshot, _wordTrackingSpan);

            if (wordSpan.IsSome() &&
                _wordCompletionSet.SelectionStatus != null &&
                _wordCompletionSet.SelectionStatus.Completion != null)
            {
                _textView.TextBuffer.Replace(wordSpan.Value, _wordCompletionSet.SelectionStatus.Completion.InsertionText);
            }

            return(true);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Get all of the values which map to the given ITextSnapshot
 /// </summary>
 private IEnumerable <ITagSpan <OutliningRegionTag> > GetRegions(ITextSnapshot snapshot)
 {
     foreach (var cur in _map.Values)
     {
         var option = TrackingSpanUtil.GetSpan(snapshot, cur.TrackingSpan);
         if (option.IsSome())
         {
             var tag = new OutliningRegionTag(cur.Text, cur.Hint);
             yield return(new TagSpan <OutliningRegionTag>(option.Value, tag));
         }
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Should we ignore this SnapshotSpan when considering it for an external edit?
        /// </summary>
        private bool ShouldIgnore(SnapshotSpan externalEditSpan)
        {
            foreach (var ignoreTrackingSpan in _ignoredExternalEditSpans)
            {
                var ignoreSpan = TrackingSpanUtil.GetSpan(externalEditSpan.Snapshot, ignoreTrackingSpan);
                if (ignoreSpan.IsSome() && ignoreSpan.Value.OverlapsWith(externalEditSpan))
                {
                    return true;
                }
            }

            return false;
        }
Exemplo n.º 4
0
        void IWordCompletionSession.Dismiss()
        {
            /// to Dismiss, we need to replace the wordSpan (which holds the text inserted by C-n/C-p)
            /// by the _initialText before completion was started
            var wordSpan = TrackingSpanUtil.GetSpan(_textView.TextSnapshot, _wordTrackingSpan);

            if (wordSpan.IsSome())
            {
                _textView.TextBuffer.Replace(wordSpan.Value, _initialText);
            }
            _isDismissed = true;
            _completionSession.Dismiss();
        }