private @Nullable("null means invalid") TextRange findNearestTextRange(int startOffset) {
    TextRange textRange = null;
    for (Segment marker : getHostRanges()) {
      TextRange curRange = ProperTextRange.create(marker);
      if (curRange.getStartOffset() > startOffset && textRange != null) break;
      textRange = curRange;
    }
    return textRange;
  }
private @Nullable("null means invalid") TextRange findNearestTextRange(int startOffset)