private bool DeleteSelection()
{
var selectionStart = SelectionStart;
var selectionEnd = SelectionEnd;
if (selectionStart != selectionEnd)
{
var start = Math.Min(selectionStart, selectionEnd);
var end = Math.Max(selectionStart, selectionEnd);
TextDocument.Remove(start, end - start);
TextView.Invalidate();
SelectionStart = SelectionEnd = CaretIndex = start;
return true;
}
return false;
}