int maxEnd= Integer.MIN_VALUE;
int i= computeIndexAtOffset(fPositions, region.getOffset()), n= computeIndexAtOffset(fPositions, region.getOffset() + region.getLength());
if (n - i > 2) {
List ranges= new ArrayList(n - i);
for (; i < n; i++) {
HighlightedPosition position= (HighlightedPosition) fPositions.get(i);
if (!position.isDeleted()) {
if (!position.isReadOnly())
ranges.add(position.createStyleRange());
else {
int offset= position.getOffset();
minStart= Math.min(minStart, offset);
maxEnd= Math.max(maxEnd, offset + position.getLength());
}
}
}
StyleRange[] array= new StyleRange[ranges.size()];
array= (StyleRange[]) ranges.toArray(array);
textPresentation.replaceStyleRanges(array);
} else {
for (; i < n; i++) {
HighlightedPosition position= (HighlightedPosition) fPositions.get(i);
if (!position.isDeleted()) {
if (!position.isReadOnly())
textPresentation.replaceStyleRange(position.createStyleRange());
else {
int offset= position.getOffset();
minStart= Math.min(minStart, offset);
maxEnd= Math.max(maxEnd, offset + position.getLength());
}
}
}
}
if (minStart < maxEnd) {