splitImmutable method
Splits this rope at position, returning two new Ropes (immutable)
Implementation
(Rope, Rope) splitImmutable(int position) {
if (position < 0 || position > length) {
throw RangeError('Invalid position: $position for length $length');
}
if (position == 0) {
return (Rope(''), Rope._fromBridge(_rope.copy()));
}
if (position == length) {
return (Rope._fromBridge(_rope.copy()), Rope(''));
}
final leftText = _rope.slice(
start: BigInt.zero,
end: BigInt.from(position),
);
final rightText = _rope.slice(
start: BigInt.from(position),
end: BigInt.from(length),
);
return (Rope(leftText), Rope(rightText));
}