void (@NotNull Side side, int offset1, int offset2, int lines1, int lines2, int startLine1, int startLine2) { int lines = side.select(lines1, lines2); boolean notEmpty = lines >= 0; int appendix = notEmpty ? 1 : 0; if (startLine1 != -1) { myConvertor1.put(totalLines, startLine1, lines + appendix, lines1 + appendix); } if (startLine2 != -1) { myConvertor2.put(totalLines, startLine2, lines + appendix, lines2 + appendix); } if (notEmpty) { Document document = side.select(myDocument1, myDocument2); int newline = document.getTextLength() > offset2 + 1 ? 1 : 0; TextRange base = new TextRange(myBuilder.length(), myBuilder.length() + offset2 - offset1 + newline); TextRange changed = new TextRange(offset1, offset2 + newline); myRanges.add(new HighlightRange(side, base, changed)); myBuilder.append(document.getCharsSequence().subSequence(offset1, offset2)); myBuilder.append('\n'); totalLines += lines + 1; } }