提交 fdde1237 编写于 作者: D David Barbet

Cancel transaction if there is no document to format.

上级 c0e34cd0
...@@ -142,8 +142,15 @@ internal bool ExecuteCommand(ITextView textView, ITextBuffer subjectBuffer, TCom ...@@ -142,8 +142,15 @@ internal bool ExecuteCommand(ITextView textView, ITextBuffer subjectBuffer, TCom
using (var transaction = new CaretPreservingEditTransaction(title, textView, _undoHistoryRegistry, _editorOperationsFactoryService)) using (var transaction = new CaretPreservingEditTransaction(title, textView, _undoHistoryRegistry, _editorOperationsFactoryService))
{ {
var formattedDocument = Format(service, subjectBuffer.CurrentSnapshot, trackingSnapshotSpans, CancellationToken.None); var formattedDocument = Format(service, subjectBuffer.CurrentSnapshot, trackingSnapshotSpans, CancellationToken.None);
formattedDocument?.Project.Solution.Workspace.ApplyDocumentChanges(formattedDocument, CancellationToken.None); if (formattedDocument == null)
transaction.Complete(); {
transaction.Cancel();
}
else
{
formattedDocument.Project.Solution.Workspace.ApplyDocumentChanges(formattedDocument, CancellationToken.None);
transaction.Complete();
}
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册