TextRange (@NotNull TextRange range) { int newStart = Math.max(getStartOffset(), range.getStartOffset()); int newEnd = Math.min(getEndOffset(), range.getEndOffset()); assertProperRange(newStart, newEnd, "Invalid range"); return new InsertionRange(newStart, newEnd); }