void (IncrementalCacheUpdateEvent event) { Document document = myEditor.getDocument(); int lineCount = document.getLineCount(); int offset = event.getStartOffset(); int line = document.getLineNumber(offset); int mandatoryEnd = event.getMandatoryEndOffset(); while (true) { if ((offset += QUICK_WRAP_CHAR_COUNT) >= document.getLineEndOffset(line)) { if (++line >= lineCount) { offset = document.getTextLength(); break; } offset = document.getLineStartOffset(line); if (offset > mandatoryEnd && myEditor.getFoldingModel().getCollapsedRegionAtOffset(offset - 1) == null) break; else continue; } FoldRegion foldRegion = myEditor.getFoldingModel().getCollapsedRegionAtOffset(offset); if (foldRegion != null) { offset = foldRegion.getEndOffset(); line = document.getLineNumber(offset); } if (DocumentUtil.isInsideSurrogatePair(document, offset)) offset++; if (offset < document.getLineEndOffset(line)) { SoftWrapImpl wrap = new SoftWrapImpl(new TextChangeImpl("\n", offset), 1, 1); myStorage.storeOrReplace(wrap); if (offset > mandatoryEnd && myDataMapper.matchesOldSoftWrap(wrap, event.getLengthDiff())) break; } } event.setActualEndOffset(offset); }