internal void OnTransactionClosed(BasicUndoTransaction transaction, bool didComplete)
        {
            if (_openTransactionStack.Count == 0 || transaction != _openTransactionStack.Peek())
            {
                // Happens in dispose after complete / cancel
                return;
            }

            _openTransactionStack.Pop();
            if (!didComplete)
            {
                return;
            }

            if (_openTransactionStack.Count == 0)
            {
                _undoStack.Push(transaction);
                var list = _undoTransactionCompleted;
                if (list != null)
                {
                    list(this, new TextUndoTransactionCompletedEventArgs(null, TextUndoTransactionCompletionResult.TransactionAdded));
                }
            }
            else
            {
                foreach (var cur in transaction.UndoPrimitives)
                {
                    _openTransactionStack.Peek().UndoPrimitives.Add(cur);
                }
            }
        }
        internal void OnTransactionClosed(BasicUndoTransaction transaction, bool didComplete)
        {
            if (_openTransactionStack.Count == 0 || transaction != _openTransactionStack.Peek())
            {
                // Happens in dispose after complete / cancel
                return;
            }

            _openTransactionStack.Pop();
            if (!didComplete)
            {
                return;
            }

            if (_openTransactionStack.Count == 0)
            {
                _undoStack.Push(transaction);
                var list = _undoTransactionCompleted;
                if (list != null)
                {
                    list(this, new TextUndoTransactionCompletedEventArgs(null, TextUndoTransactionCompletionResult.TransactionAdded));
                }
            }
            else
            {
                foreach (var cur in transaction.UndoPrimitives)
                {
                    _openTransactionStack.Peek().UndoPrimitives.Add(cur);
                }
            }
        }