DiffIterable (@NotNull CodePointsOffsets codePoints1, @NotNull CodePointsOffsets codePoints2, @NotNull CharSequence text1, @NotNull CharSequence text2, @NotNull FairDiffIterable changes) { final List<Range> ranges = new ArrayList<>(); for (Range ch : changes.iterateChanges()) { int startOffset1; int endOffset1; if (ch.start1 == ch.end1) { startOffset1 = endOffset1 = expandForwardW(codePoints1, codePoints2, text1, text2, ch, true); } else { startOffset1 = codePoints1.charOffset(ch.start1); endOffset1 = codePoints1.charOffsetAfter(ch.end1 - 1); } int startOffset2; int endOffset2; if (ch.start2 == ch.end2) { startOffset2 = endOffset2 = expandForwardW(codePoints1, codePoints2, text1, text2, ch, false); } else { startOffset2 = codePoints2.charOffset(ch.start2); endOffset2 = codePoints2.charOffsetAfter(ch.end2 - 1); } ranges.add(new Range(startOffset1, endOffset1, startOffset2, endOffset2)); } return create(ranges, text1.length(), text2.length()); }