void (@NotNull List<? extends LineFragment> oldFragments, @NotNull Consumer<? super List<? extends LineFragment>> consumer) { int startIndex = 0; for (int i = 1; i < oldFragments.size(); i++) { if (!isAdjoining(oldFragments.get(i - 1), oldFragments.get(i))) { consumer.consume(oldFragments.subList(startIndex, i)); startIndex = i; } } if (startIndex < oldFragments.size()) { consumer.consume(oldFragments.subList(startIndex, oldFragments.size())); } }