提交 6ab98c48 编写于 作者: S Sam Harwell

Simplify code using CaretPreservingEditTransaction

上级 9e486c21
......@@ -55,9 +55,6 @@ public CompleteStatementCommandHandler(ITextUndoHistoryRegistry textUndoHistoryR
public void ExecuteCommand(TypeCharCommandArgs args, Action nextCommandHandler, CommandExecutionContext executionContext)
{
var history = _textUndoHistoryRegistry.GetHistory(args.SubjectBuffer);
var operations = _editorOperationsFactoryService.GetEditorOperations(args.TextView);
var willMoveSemicolon = BeforeExecuteCommand(speculative: true, args: args, executionContext: executionContext);
if (!willMoveSemicolon)
{
......@@ -66,9 +63,7 @@ public void ExecuteCommand(TypeCharCommandArgs args, Action nextCommandHandler,
return;
}
using var transaction = new HACK_TextUndoTransactionThatRollsBackProperly(history.CreateTransaction(nameof(CompleteStatementCommandHandler)));
operations.AddBeforeTextBufferChangePrimitive();
using var transaction = CaretPreservingEditTransaction.TryCreate(CSharpEditorResources.Complete_statement_on_semicolon, args.TextView, _textUndoHistoryRegistry, _editorOperationsFactoryService);
// Determine where semicolon should be placed and move caret to location
BeforeExecuteCommand(speculative: false, args: args, executionContext: executionContext);
......@@ -76,8 +71,6 @@ public void ExecuteCommand(TypeCharCommandArgs args, Action nextCommandHandler,
// Insert the semicolon using next command handler
nextCommandHandler();
operations.AddAfterTextBufferChangePrimitive();
transaction.Complete();
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册