TextRange (@NotNull CharSequence charSequence, int offset) { final int length = charSequence.length(); final char c = charSequence.charAt(offset); int l = offset, r = offset; while (l - 1 >= 0 && charSequence.charAt(l - 1) == c) { l--; } while (r + 1 < length && charSequence.charAt(r + 1) == c) { r++; } return TextRange.create(l, r + 1); }