spyglass/src/main/java/com/linkedin/android/spyglass/ui/MentionsEditText.java
private void replaceMentionSpansWithPlaceholdersAsNecessary(@NonNull CharSequence text) {
        int index = getSelectionStart();
        int wordStart = findStartOfWord(text, index);
        Editable editable = getText();
        MentionSpan[] mentionSpansInCurrentWord = editable.getSpans(wordStart, index, MentionSpan.class);
        for (MentionSpan span : mentionSpansInCurrentWord) {
            if (span.getDisplayMode() != Mentionable.MentionDisplayMode.NONE) {
                int spanStart = editable.getSpanStart(span);
                int spanEnd = editable.getSpanEnd(span);
                editable.setSpan(new PlaceholderSpan(span, spanStart, spanEnd),
                        spanStart, spanEnd, Spanned.SPAN_EXCLUSIVE_INCLUSIVE);
                editable.removeSpan(span);
            }
        }
    }
private void replaceMentionSpansWithPlaceholdersAsNecessary(@NonNull CharSequence text) {
        int index = getSelectionStart();
        int wordStart = findStartOfWord(text, index);
        Editable editable = getText();
        MentionSpan[] mentionSpansInCurrentWord = editable.getSpans(wordStart, index, MentionSpan.class);
        for (MentionSpan span : mentionSpansInCurrentWord) {
            if (span.getDisplayMode() != Mentionable.MentionDisplayMode.NONE) {
                int spanStart = editable.getSpanStart(span);
                int spanEnd = editable.getSpanEnd(span);
                editable.setSpan(new PlaceholderSpan(span, spanStart, spanEnd),
                        spanStart, spanEnd, Spanned.SPAN_EXCLUSIVE_INCLUSIVE);
                editable.removeSpan(span);
            }
        }
    }
Temporarily remove MentionSpans that may interfere with composing text. Note that software keyboards are allowed
to place arbitrary spans over the text. This was resulting in several bugs in edge cases while handling the
MentionSpans while composing text (with different issues for different keyboards). The easiest solution for this
is to remove any MentionSpans that could cause issues while the user is changing text.

Note: The MentionSpans are added again in {@link #replacePlaceholdersWithCorrespondingMentionSpans(Editable)}

@param text the current text before it changes