Example #1
0
        internal void RaiseChangingEvent(TextContentChangingEventArgs args)
        {
            var changing = this.Changing;

            if (changing != null)
            {
                foreach (Delegate handlerDelegate in changing.GetInvocationList())
                {
                    var handler = (EventHandler <TextContentChangingEventArgs>)handlerDelegate;
                    try
                    {
                        handler(this, args);
                    }
                    catch (Exception e)
                    {
                        this.guardedOperations.HandleException(handler, e);
                    }

                    if (args.Canceled)
                    {
                        return;
                    }
                }
            }
        }
        private void OnTextBufferChanging(object sender, TextContentChangingEventArgs e)
        {
            var methodOccurence = _codeBlockOccurrences
                                  .Where(occurence => occurence.Block.FullSpan.IntersectsWith(_view.Caret.Position.BufferPosition.Position))
                                  .Select(occurence => occurence)
                                  .FirstOrDefault();

            string methodName  = string.Empty;
            int    linesOfCode = 0;

            GetMethodNameAndLineCount(methodOccurence.Block, out methodName, out linesOfCode);

            var feedbacks = _feedbackMachine.RequestFeedbackBeforeMethodCodeChange(methodName, linesOfCode);

            foreach (var feedback in feedbacks)
            {
                if (feedback is InsertTextFeedback)
                {
                    InsertText(feedback);
                }
                else if (feedback is DelayKeyboardInputsFeedback)
                {
                    DelayKeyboardInput(feedback);
                }
                else if (feedback is PreventKeyboardInputsFeedback)
                {
                    e.Cancel();
                }
            }
        }
Example #3
0
 private void OnTextBufferChanging(object sender, TextContentChangingEventArgs e) {
     if (_quickInfoBroker.IsQuickInfoActive(_textView)) {
         var sessions = _quickInfoBroker.GetSessions(_textView);
         foreach (var session in sessions)
             session.Dismiss();
     }
 }
 private void Textbuffer_Changing(object sender, TextContentChangingEventArgs e)
 {
     if (XSettings.DebuggerIsRunning)
     {
         XSettings.ShowMessageBox("Cannot edit source code while debugging");
         e.Cancel();
     }
 }
 void TextBufferChanging(object sender, TextContentChangingEventArgs e)
 {
     // See if somebody (other than us) is trying to edit the buffer during undo/redo.
     if (_undoHistory.State != TextUndoHistoryState.Idle &&
         (e.EditTag as Type) != typeof(TextBufferChangeUndoPrimitive))
     {
         Debug.Fail("Attempt to edit the buffer during undo/redo has been denied.  This is explicitly prohibited as it would corrupt the undo stack!  Please fix your code.");
         e.Cancel();
     }
 }
Example #6
0
        void textBuffer_Changing(object sender, TextContentChangingEventArgs e)
        {
            List <Tuple <int, string> > errorLines;

            if (VSIntegration.ErrorLines.TryGetValue(this.fileName, out errorLines))
            {
                errorLines.Clear();
                OnTagsChanged();
            }
        }
Example #7
0
 protected Edit(BaseBuffer baseBuffer, ITextSnapshot originSnapshot, EditOptions options, int?reiteratedVersionNumber, Object editTag)
     : base(baseBuffer, originSnapshot, editTag)
 {
     this.bufferLength            = originSnapshot.Length;
     this.changes                 = new FrugalList <TextChange>();
     this.options                 = options;
     this.reiteratedVersionNumber = reiteratedVersionNumber;
     this.raisedChangingEventArgs = null;
     this.cancelAction            = null;
     this.hasFailedChanges        = false;
 }
Example #8
0
 private void OnTextBufferChanging(object sender, TextContentChangingEventArgs e)
 {
     if (_quickInfoBroker.IsQuickInfoActive(_textView))
     {
         var sessions = _quickInfoBroker.GetSessions(_textView);
         foreach (var session in sessions)
         {
             session.Dismiss();
         }
     }
 }
        private void TextBufferOnChanging(object sender, TextContentChangingEventArgs eventArgs)
        {
            var buffer    = Helpers.GetRootTextBuffer(eventArgs.Before.TextBuffer);
            var view      = buffer.Properties["view"] as ITextView;
            var bookmarks = bookmarksByView[view];

            foreach (var bookmark in bookmarks)
            {
                bookmark.LineNumberBeforeChanging = bookmark.GetRow(buffer);
            }
        }
 private void HandleTextChanging(object sender, TextContentChangingEventArgs e)
 {
     // If we are in multi-edit mode then look to see if the change is applied
     // to the version we were expecting to edit - if not then we assume this
     // is an auto-format change which we do not want
     if (this.InMultiEditMode &&
         this.expectedEditVersion != null &&
         e.BeforeVersion != this.expectedEditVersion)
     {
         e.Cancel();
     }
 }
Example #11
0
 private void HandleTextBufferChanging(object sender, TextContentChangingEventArgs e)
 {
     //Prevent the text from changing while the margin is visible, since the text needs to be loaded when the
     //margin is shown, and this keeps it consistent.
     //The second disjunct makes sure that a conversation is currently happening. It also makes sure that edits are not tagged
     //with the context manager. Edits made by the manager in response to a client sending edited code back should not be cancelled,
     //and will be tagged with the manager. Edits made by the user directly have no tag and need to be cancelled while a conversation
     //is happening to prevent the concurrent modification.
     if (ViewSearchMargin.ActualWidth > 0 || (_manager != null && _manager.Started && e.EditTag != _manager))
     {
         e.Cancel();
     }
 }
Example #12
0
 void TextBufferChanging(object sender, TextContentChangingEventArgs e)
 {
     // Note that VB explicitly forces undo edits to happen while the history is idle so we need to allow this here
     // by always doing nothing for undo edits). This may be a bug in our code (e.g. not properly cleaning up when
     // an undo transaction is cancelled in mid-flight) but changing that will require coordination with Roslyn.
     if (!(e.EditTag is IUndoEditTag))
     {
         if (this.TextBufferUndoHistory.State != TextUndoHistoryState.Idle)
         {
             Debug.Fail("We are doing a normal edit in a non-idle undo state. This is explicitly prohibited as it would corrupt the undo stack!  Please fix your code.");
             e.Cancel();
         }
     }
 }
Example #13
0
 // copied from BaseBuffer.Edit. Could arrange to inherit.
 public bool CheckForCancellation(Action cancelationResponse)
 {
     Debug.Assert(this.raisedChangingEventArgs == null, "just checking");
     if (this.raisedChangingEventArgs == null)
     {
         this.cancelAction            = cancelationResponse;
         this.raisedChangingEventArgs = new TextContentChangingEventArgs(this.originSnapshot, this.editTag, (args) =>
         {
             this.Cancel();
         });
         this.baseBuffer.RaiseChangingEvent(this.raisedChangingEventArgs);
     }
     this.canceled = this.raisedChangingEventArgs.Canceled;
     return(!this.raisedChangingEventArgs.Canceled);
 }
Example #14
0
        bool RaiseChangingGetIsCanceled(object editTag)
        {
            var c = Changing;

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

            Action <TextContentChangingEventArgs> cancelAction = null;
            var args = new TextContentChangingEventArgs(CurrentSnapshot, editTag, cancelAction);

            foreach (EventHandler <TextContentChangingEventArgs> handler in c.GetInvocationList())
            {
                handler(this, args);
                if (args.Canceled)
                {
                    break;
                }
            }
            return(args.Canceled);
        }
Example #15
0
            /// <summary>
            /// Checks whether the edit on the buffer is allowed to continue.
            /// </summary>
            /// <param name="cancelationResponse">Additional action to perform if the edit itself is canceled.</param>
            public bool CheckForCancellation(Action cancelationResponse)
            {
                Debug.Assert(this.raisedChangingEventArgs == null, "just checking");

                // If no changes are being applied to this edit's buffer then there will be no new snapshot produced and
                // the Changed event won't be raised and so the cancelable Changing event should not be raised either.
                if (this.changes.Count == 0)
                {
                    return(true);
                }

                if (this.raisedChangingEventArgs == null)
                {
                    this.cancelAction            = cancelationResponse;
                    this.raisedChangingEventArgs = new TextContentChangingEventArgs(this.Snapshot, this.editTag, (args) =>
                    {
                        this.Cancel();
                    });
                    this.baseBuffer.RaiseChangingEvent(this.raisedChangingEventArgs);
                }
                this.canceled = this.raisedChangingEventArgs.Canceled;
                //Debug.Assert(!this.canceled || !this.applied, "an edit shouldn't be both canceled and applied");
                return(!this.raisedChangingEventArgs.Canceled);
            }
Example #16
0
 void CancelAction(TextContentChangingEventArgs e) { }
Example #17
0
 void CancelAction(TextContentChangingEventArgs e)
 {
 }
Example #18
0
		bool RaiseChangingGetIsCanceled(object editTag) {
			var c = Changing;
			if (c == null)
				return false;

			Action<TextContentChangingEventArgs> cancelAction = null;
			var args = new TextContentChangingEventArgs(CurrentSnapshot, editTag, cancelAction);
			foreach (EventHandler<TextContentChangingEventArgs> handler in c.GetInvocationList()) {
				handler(this, args);
				if (args.Canceled)
					break;
			}
			return args.Canceled;
		}
Example #19
0
 private void TextBuffer_Changing(object sender, TextContentChangingEventArgs e)
 {
     Wrapper.CaptureSelectionState();
 }