private void HandleTextInput(string input)
{
InvalidateSelectedWord();
if (!string.IsNullOrEmpty(input))
{
TextDocument.BeginUpdate();
DeleteSelection();
var caretIndex = CaretIndex;
if (caretIndex >= 0)
{
TextDocument.Insert(caretIndex, input);
}
TextDocument.EndUpdate();
CaretIndex += input.Length;
SelectionStart = SelectionEnd = CaretIndex;
TextView.Invalidate();
}
}