public int PasteText (int offset, string text, byte[] copyData, ref IDisposable undoGroup)
{
if (TextPasteHandler != null) {
string newText;
try {
newText = TextPasteHandler.FormatPlainText (offset, text, copyData);
} catch (Exception e) {
Console.WriteLine ("Text paste handler exception:" + e);
newText = text;
}
if (newText != text) {
var inserted = Insert (offset, text);
if (options.GenerateFormattingUndoStep) {
undoGroup.Dispose ();
undoGroup = OpenUndoGroup ();
}
var result = Replace (offset, inserted, newText);
if (Paste != null)
Paste (offset, text, result);
return result;
}
}
var insertedChars = Insert (offset, text);
if (options.GenerateFormattingUndoStep) {
undoGroup.Dispose ();
undoGroup = OpenUndoGroup ();
}
if (Paste != null)
Paste (offset, text, insertedChars);
return insertedChars;
}