unwrapLine method

void unwrapLine(
  1. LineNode line
)

Unwraps line from this block.

Implementation

void unwrapLine(LineNode line) {
  assert(children.contains(line));

  if (line.isFirst) {
    line.unlink();
    insertBefore(line);
  } else if (line.isLast) {
    line.unlink();
    insertAfter(line);
  } else {
    /// need to split this block into two as [line] is in the middle.
    final before = clone();
    insertBefore(before);

    LineNode child = first as LineNode;
    while (child != line) {
      child.unlink();
      before.add(child);
      child = first as LineNode;
    }
    line.unlink();
    insertBefore(line);
  }
  optimize();
}