/// <summary> /// Commits all modifications made with specified <see cref="ITextBufferEdit"/> and link the commit /// with <see cref="ITextUndoTransaction"/> in the Editor, if <see cref="_undoHistory"/> is available. /// </summary> /// <param name="edit">A set of editing operations on an <see cref="ITextBuffer"/>.</param> /// <param name="description">The description of the transaction.</param> private void ApplyEdit(ITextBufferEdit edit, string description) { if (_undoHistory != null) { using (ITextUndoTransaction transaction = _undoHistory.CreateTransaction(description)) { edit.Apply(); transaction.Complete(); } } else { edit.Apply(); } }
/// <summary> /// Logs exceptions thrown during <see cref="ITextBufferEdit.Apply"/> as we look for issues. /// </summary> /// <param name="edit"></param> /// <returns></returns> public static ITextSnapshot ApplyAndLogExceptions(this ITextBufferEdit edit) { try { return(edit.Apply()); } catch (Exception e) when(ErrorReporting.FatalError.ReportWithoutCrash(e)) { s_lastException = e; // Since we don't know what is causing this yet, I don't feel safe that catching // will not cause some further downstream failure. So we'll continue to propagate. throw; } }