end method

void end()

End the compound operation, combining all recorded edits into one.

Implementation

void end() {
  if (!_isActive) return;
  _isActive = false;

  final newOps = _controller._undoStack.sublist(_startStackSize);
  if (newOps.isEmpty) return;

  _controller._undoStack.removeRange(
    _startStackSize,
    _controller._undoStack.length,
  );

  final compound = CompoundOperation(
    operations: newOps,
    selectionBefore: newOps.first.selectionBefore,
    selectionAfter: newOps.last.selectionAfter,
  );

  _controller._undoStack.add(compound);
  _controller._notifyListenersPublic();
}