ProperTextRange (@NotNull TextRange subRange) { assert subRange.getStartOffset() <= getLength() : subRange + "; this="+this; assert subRange.getEndOffset() <= getLength() : subRange + "; this="+this; return new ProperTextRange(getStartOffset() + subRange.getStartOffset(), Math.min(getEndOffset(), getStartOffset() + subRange.getEndOffset())); }