void () { int startOffset = myEvent.getStartOffset(); int minEndOffset = myEvent.getMandatoryEndOffset(); int maxEndOffset = getEndOffsetUpperEstimate(); SoftWrap lastSoftWrap = null; boolean minWrapOffsetAtFolding = false; int minWrapOffset = -1; int maxWrapOffset = -1; float nonWhitespaceStartX = 0; int nonWhitespaceStartOffset = -1; float x; if (startOffset == 0) { x = myView.getPrefixTextWidthInPixels(); } else { lastSoftWrap = myStorage.getSoftWrap(startOffset); x = lastSoftWrap == null ? 0 : lastSoftWrap.getIndentInPixels(); } WrapElementMeasuringIterator it = new WrapElementMeasuringIterator(myView, startOffset, maxEndOffset); while (!it.atEnd()) { if (it.isLineBreak()) { minWrapOffset = -1; maxWrapOffset = -1; x = 0; lastSoftWrap = null; nonWhitespaceStartOffset = -1; if (it.getElementEndOffset() > minEndOffset) { myEvent.setActualEndOffset(it.getElementEndOffset()); return; } } else { if (myRelativeIndent >= 0 && nonWhitespaceStartOffset == -1 && !it.isWhitespace()) { nonWhitespaceStartX = x; nonWhitespaceStartOffset = it.getElementStartOffset(); } x = it.getElementEndX(x); if (minWrapOffset < 0 || x <= myMaxWidthAtWrap && it.isFoldRegion()) { minWrapOffset = it.getElementEndOffset(); minWrapOffsetAtFolding = it.isFoldRegion(); } else { if (x > myMaxWidthAtWrap && maxWrapOffset < 0) { maxWrapOffset = it.getElementStartOffset(); if (maxWrapOffset > minWrapOffset && it.isFoldRegion()) minWrapOffset = maxWrapOffset; } if (x > myVisibleWidth) { lastSoftWrap = createSoftWrap(lastSoftWrap, minWrapOffset, maxWrapOffset, minWrapOffsetAtFolding, nonWhitespaceStartOffset, nonWhitespaceStartX); int wrapOffset = lastSoftWrap.getStart(); if (wrapOffset > minEndOffset && myDataMapper.matchesOldSoftWrap(lastSoftWrap, myEvent.getLengthDiff())) { myEvent.setActualEndOffset(wrapOffset); return; } minWrapOffset = -1; maxWrapOffset = -1; x = lastSoftWrap.getIndentInPixels(); if (wrapOffset <= it.getElementStartOffset()) { it.retreat(wrapOffset); continue; } } } } it.advance(); } myEvent.setActualEndOffset(maxEndOffset); }