public ISourceTextUndoTransaction RegisterUndoTransaction(SourceText sourceText, string description)
        {
            if (sourceText != null && !string.IsNullOrWhiteSpace(description))
            {
                var transaction = new SourceTextUndoTransaction(this, sourceText, description);
                _transactions.Add(sourceText, transaction);
                return(transaction);
            }

            return(null);
        }
        public ISourceTextUndoTransaction RegisterUndoTransaction(SourceText sourceText, string description)
        {
            if (sourceText != null && !string.IsNullOrWhiteSpace(description))
            {
                var transaction = new SourceTextUndoTransaction(this, sourceText, description);
                _transactions.Add(sourceText, transaction);
                return transaction;
            }

            return null;
        }
        public bool BeginUndoTransaction(ITextSnapshot snapshot)
        {
            SourceTextUndoTransaction transaction = null;
            var sourceText = snapshot?.AsText();

            if (sourceText != null)
            {
                _transactions.TryGetValue(sourceText, out transaction);
                if (transaction != null)
                {
                    return(transaction.Begin(_undoHistoryRegistry?.GetHistory(snapshot.TextBuffer)));
                }
            }

            return(false);
        }