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();
                }
            }
        }
 private void Textbuffer_Changing(object sender, TextContentChangingEventArgs e)
 {
     if (XSettings.DebuggerIsRunning)
     {
         XSettings.ShowMessageBox("Cannot edit source code while debugging");
         e.Cancel();
     }
 }
Exemplo n.º 3
0
 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();
     }
 }
Exemplo n.º 4
0
 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();
     }
 }
Exemplo n.º 5
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();
     }
 }
Exemplo n.º 6
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();
         }
     }
 }