delete method

void delete(
  1. int start,
  2. int end
)

Implementation

void delete(int start, int end) {
  final safeStart = start.clamp(0, length);
  final safeEnd = end.clamp(safeStart, length);
  if (safeStart == safeEnd) return;
  _root.remove(safeStart, safeEnd);
  if (_root is _RopeInternal && (_root as _RopeInternal).children.isEmpty) {
    _root = _RopeLeaf('');
  }
  while (_root is _RopeInternal &&
      (_root as _RopeInternal).children.length == 1) {
    _root = (_root as _RopeInternal).children.single;
  }
}