replaceWith method

bool replaceWith (
  1. TextBit another
)

Replaces self with another.

Implementation

bool replaceWith(TextBit another) {
  if (parent == null) return false;

  assert(parent == another.parent);
  final siblings = parent._children;
  final i = siblings.indexOf(this);
  if (i == -1) return false;

  siblings[i] = another;
  return true;
}