public void SetText(string text)
{
Document.StartUndoCapture();
var tp = new TextPoint(0, Index);
var tr = new TextRange {FirstColumn = 0, FirstRow = tp.Y, LastColumn = Text.Length, LastRow = tp.Y};
Document.StartUndoCapture();
//delete the current line
Document.PushUndoBlock(UndoAction.DeleteRange, Document.GetRange(tr), tr.FirstColumn, tr.FirstRow);
//alter the text
Document.PushUndoBlock(UndoAction.InsertRange, text, tp.X, tp.Y);
Text = text;
Document.EndUndoCapture();
Document.InvokeChange();
}