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

Cancel transaction if there is no document to format.

上级 c0e34cd0
......@@ -142,10 +142,17 @@ internal bool ExecuteCommand(ITextView textView, ITextBuffer subjectBuffer, TCom
using (var transaction = new CaretPreservingEditTransaction(title, textView, _undoHistoryRegistry, _editorOperationsFactoryService))
{
var formattedDocument = Format(service, subjectBuffer.CurrentSnapshot, trackingSnapshotSpans, CancellationToken.None);
formattedDocument?.Project.Solution.Workspace.ApplyDocumentChanges(formattedDocument, CancellationToken.None);
if (formattedDocument == null)
{
transaction.Cancel();
}
else
{
formattedDocument.Project.Solution.Workspace.ApplyDocumentChanges(formattedDocument, CancellationToken.None);
transaction.Complete();
}
}
}
var spansToSelect = trackingSnapshotSpans.Select(s => new Selection(s));
// Set the multi selection with the last selection as the primary after edits have been applied.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册