The buffer now emits a new event 'update-anchors-after-change' to signal that all the anchors have been updated, which is an appropriate time to merge cursors.
UndoManager.prototype.transact
Buffer
UndoManager