spyglass/src/main/java/com/linkedin/android/spyglass/ui/MentionsEditText.java
private void updateSelectionIfRequired(final int selStart, final int selEnd) {
        MentionsEditable text = getMentionsText();
        MentionSpan startMentionSpan = text.getMentionSpanAtOffset(selStart);
        MentionSpan endMentionSpan = text.getMentionSpanAtOffset(selEnd);
        boolean selChanged = false;
        int start = selStart;
        int end = selEnd;
        if (text.getSpanStart(startMentionSpan) < selStart && selStart < text.getSpanEnd(startMentionSpan)) {
            start = text.getSpanStart(startMentionSpan);
            selChanged = true;
        }
        if (text.getSpanStart(endMentionSpan) < selEnd && selEnd < text.getSpanEnd(endMentionSpan)) {
            end = text.getSpanEnd(endMentionSpan);
            selChanged = true;
        }
        if (selChanged) {
            setSelection(start, end);
        }
    }
private void updateSelectionIfRequired(final int selStart, final int selEnd) {
        MentionsEditable text = getMentionsText();
        MentionSpan startMentionSpan = text.getMentionSpanAtOffset(selStart);
        MentionSpan endMentionSpan = text.getMentionSpanAtOffset(selEnd);
        boolean selChanged = false;
        int start = selStart;
        int end = selEnd;
        if (text.getSpanStart(startMentionSpan) < selStart && selStart < text.getSpanEnd(startMentionSpan)) {
            start = text.getSpanStart(startMentionSpan);
            selChanged = true;
        }
        if (text.getSpanStart(endMentionSpan) < selEnd && selEnd < text.getSpanEnd(endMentionSpan)) {
            end = text.getSpanEnd(endMentionSpan);
            selChanged = true;
        }
        if (selChanged) {
            setSelection(start, end);
        }
    }
Don't allow user to set starting position or ending position of selection within the mention.