Couple<List<Range>> (@NotNull FairDiffIterable changes, int offset) { final List<Range> ranges1 = new ArrayList<>(); final List<Range> ranges2 = new ArrayList<>(); for (Range ch : changes.iterateUnchanged()) { if (ch.end2 <= offset) { ranges1.add(new Range(ch.start1, ch.end1, ch.start2, ch.end2)); } else if (ch.start2 >= offset) { ranges2.add(new Range(ch.start1, ch.end1, ch.start2 - offset, ch.end2 - offset)); } else { int len2 = offset - ch.start2; ranges1.add(new Range(ch.start1, ch.start1 + len2, ch.start2, offset)); ranges2.add(new Range(ch.start1 + len2, ch.end1, 0, ch.end2 - offset)); } } return Couple.of(ranges1, ranges2); }