}
public List<Line> get(IntRange region) {
int to = region.getTo();
IntRange newRange = new IntRange(region);
newRange.setTo(Math.min(to + GloogyConstants.LINE_CUTOFF, text.length()));
IntList list = index.get(newRange);
if (list == null) {
throw new NullPointerException("unable to index range " + newRange + " length of input " + text.length());
}
List<Line> l = new ArrayList<Line>(list.size());
int[] values = list.toArray(new int[list.size()]);
int lineStart = 0;
int lineEnd = 0;
for (int i = 0; i < values.length; i++) {
lineStart = values[i];
if (lineStart >= to)
break;
// TODO should we extend the search area?
lineEnd = (i == values.length - 1) ? newRange.getTo() : values[i + 1];
// TODO check if this is safe, strip newlines
lineEnd--;
Line line = buildLine(lineStart, lineEnd);