提交 7a71038c 编写于 作者: J Jason Malinowski

Call the transaction creationg helper function and move it

上级 c18bf5ff
......@@ -50,10 +50,5 @@ private void ExecuteCommand(TypeCharCommandArgs args, Action nextHandler, Cancel
return true;
}
private CaretPreservingEditTransaction CreateEditTransaction(ITextView view, string description)
{
return new CaretPreservingEditTransaction(description, view, _undoHistoryRegistry, _editorOperationsFactoryService);
}
}
}
......@@ -53,7 +53,7 @@ private void Format(ITextView textView, Document document, TextSpan? selectionOp
var formattingService = document.GetLanguageService<IEditorFormattingService>();
using (Logger.LogBlock(FunctionId.CommandHandler_FormatCommand, KeyValueLogMessage.Create(LogType.UserAction, m => m["Span"] = selectionOpt?.Length ?? -1), cancellationToken))
using (var transaction = new CaretPreservingEditTransaction(EditorFeaturesResources.Formatting, textView, _undoHistoryRegistry, _editorOperationsFactoryService))
using (var transaction = CreateEditTransaction(textView, EditorFeaturesResources.Formatting))
{
var changes = formattingService.GetFormattingChangesAsync(document, selectionOpt, cancellationToken).WaitAndGetResult(cancellationToken);
if (changes.Count == 0)
......@@ -176,5 +176,10 @@ public void ExecuteReturnOrTypeCommand(EditorCommandArgs args, Action nextHandle
// caret has moved to wrong position, move it back to correct position
args.TextView.TryMoveCaretToAndEnsureVisible(oldCaretPosition);
}
private CaretPreservingEditTransaction CreateEditTransaction(ITextView view, string description)
{
return new CaretPreservingEditTransaction(description, view, _undoHistoryRegistry, _editorOperationsFactoryService);
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册