Does this look reasonable? I'm guessing that GetTextChange(0) always returns the most recent item in the stack but I can't see that documented anywhere...
private static bool IsTypingSelectionChange(ITextView view)
{
var undoStack = view.SyntaxEditor.Document.UndoHistory.UndoStack;
if (undoStack.Count > 0)
{
var change = undoStack.GetTextChange(0);
if (change.Operations.Count == 1)
{
var operation = change.Operations[0];
if (operation.HasInsertion && operation.InsertionEndOffset == view.SyntaxEditor.Caret.Offset)
{
return true;
}
if (operation.HasDeletion && (operation.DeletionEndOffset - operation.DeletionLength) == view.SyntaxEditor.Caret.Offset)
{
return true;
}
}
}
return false;
}