retain method

  1. @override
void retain(
  1. int index,
  2. int? length,
  3. NotusStyle? style
)
override

Format length characters of this node starting from index with specified style style.

Implementation

@override
void retain(int index, int? length, NotusStyle? style) {
  if (style == null) return;

  final local = math.min(this.length - index, length!);
  final node = isolate(index, local);

  final remaining = length - local;
  if (remaining > 0) {
    assert(node.next != null);
    node.next!.retain(0, remaining, style);
  }
  // Optimize at the very end
  node.formatAndOptimize(style);
}