reset method
void
reset()
Erases all cells and resets per-line state (isWrapped, anchors) so the line can be reused as a fresh empty line. Used to recycle scrolled-out lines instead of allocating a new BufferLine per scrolled line.
Only cells below the _occ high-water mark are cleared: cells at or
beyond it were never written since the last reset and are known to be
zero already, so a short line does not pay for clearing the whole
(capacity-sized) backing store.
Implementation
void reset() {
if (_occ > 0) {
_data.fillRange(0, _occ * _cellSize, 0);
_occ = 0;
}
isWrapped = false;
version++;
// Detach anchors that still point at this line (e.g. selection ends) so
// they don't silently follow the line into its new position. Iterate
// backwards: disposing an anchor removes it from [_anchors].
for (var i = _anchors.length - 1; i >= 0; i--) {
_anchors[i].dispose();
}
}