int getLineAtOffset(int charOffset) { final offset = charOffset.clamp(0, length); return _root.newlinesBefore(offset); }