Exemplo n.º 1
0
        public void Replace(int offset, int count, string value, ICSharpCode.NRefactory.Editor.AnchorMovementType anchorMovementType = AnchorMovementType.Default)
        {
            if (offset < 0)
            {
                throw new ArgumentOutOfRangeException("offset", "must be > 0, was: " + offset);
            }
            if (offset > TextLength)
            {
                throw new ArgumentOutOfRangeException("offset", "must be <= Length, was: " + offset);
            }
            if (count < 0)
            {
                throw new ArgumentOutOfRangeException("count", "must be > 0, was: " + count);
            }

            //InterruptFoldWorker();
            //int oldLineCount = LineCount;
            var args = new DocumentChangeEventArgs(offset, count > 0 ? GetTextAt(offset, count) : "", value, anchorMovementType);

            OnTextReplacing(args);
            value = args.InsertedText.Text;

            /*UndoOperation operation = null;
             * if (!isInUndo)
             * {
             *  operation = new UndoOperation(args);
             *  if (currentAtomicOperation != null)
             *  {
             *      currentAtomicOperation.Add(operation);
             *  }
             *  else
             *  {
             *      OnBeginUndo();
             *      undoStack.Push(operation);
             *      OnEndUndo(new UndoOperationEventArgs(operation));
             *  }
             *  redoStack.Clear();
             * }*/

            buffer.Replace(offset, count, value);
            //foldSegmentTree.UpdateOnTextReplace(this, args);
            splitter.TextReplaced(this, args);
            versionProvider.AppendChange(args);
            OnTextReplaced(args);
        }