TextRange (@NotNull TextRange subRange) { if (subRange.getStartOffset() > getLength()) { throw new IllegalArgumentException("SubRange: " + subRange + "; this=" + this); } if (subRange.getEndOffset() > getLength()) { throw new IllegalArgumentException("SubRange: " + subRange + "; this=" + this); } assertProperRange(subRange); return new TextRange(myStartOffset + subRange.getStartOffset(), Math.min(myEndOffset, myStartOffset + subRange.getEndOffset())); }