/// <summary> /// Undoes a replace operation. /// </summary> /// <param name="model">The model.</param> private void UndoReplace(DocumentModel doc, OpReplaceMessage model, ITextEdit edit) { //doc.BlockEvent = true; var span = new Span(model.Index, model.Content.Length); edit.Replace(span, model.OldContent); }
/// <summary> /// Performs a replace in a document. /// </summary> /// <param name="model">The model.</param> private void Replace(DocumentModel doc, OpReplaceMessage model, ITextEdit edit) { //doc.BlockEvent = true; var start = model.Index; var length = model.OldContent.Length; if (start > edit.Snapshot.Length - length) { start = edit.Snapshot.Length - length; } if (model.TickStamp == 0) { length = edit.Snapshot.Length; } var span = new Span(start, length); edit.Replace(span, model.Content); }