void (@NotNull Document document, int line1, int line2) { TextRange range = getLinesRange(document, line1, line2); int offset1 = range.getStartOffset(); int offset2 = range.getEndOffset(); if (offset1 > 0) { offset1--; } else if (offset2 < document.getTextLength()) { offset2++; } document.deleteString(offset1, offset2); }