void (@NotNull MarkupModelEx model, @NotNull HighlightRange range) { final TextRange base = range.getBase(); final TextRange changed = range.getChanged(); final int changedLength = changed.getEndOffset() - changed.getStartOffset(); model.processRangeHighlightersOverlappingWith(changed.getStartOffset(), changed.getEndOffset(), marker -> { int relativeStart = Math.max(marker.getStartOffset() - changed.getStartOffset(), 0); int relativeEnd = Math.min(marker.getEndOffset() - changed.getStartOffset(), changedLength); int newStart = base.getStartOffset() + relativeStart; int newEnd = base.getStartOffset() + relativeEnd; if (newEnd - newStart <= 0) return true; if (myPieces.size() % 1014 == 0) ProgressManager.checkCanceled(); myPieces.add(new Element(marker, newStart, newEnd)); return true; }); }