code: private void markDuplicatedTextForDeletionLater(@NonNull Editable text, int cursor, @NonNull Tokenizer tokenizer) {
          while (cursor > 0 && tokenizer.isWordBreakingChar(text.charAt(cursor - 1))) {
              cursor--;
          }
          int wordStart = findStartOfWord(text, cursor);
          PlaceholderSpan[] placeholderSpans = text.getSpans(wordStart, wordStart + 1, PlaceholderSpan.class);
          for (PlaceholderSpan span : placeholderSpans) {
              int spanEnd = span.originalEnd;
              int copyEnd = spanEnd + (spanEnd - wordStart);
              if (copyEnd > spanEnd && copyEnd <= text.length()) {
                  CharSequence endOfMention = text.subSequence(wordStart, spanEnd);
                  CharSequence copyOfEndOfMentionText = text.subSequence(spanEnd, copyEnd);
                  // Note: Comparing strings since we do not want to compare any other aspects of spanned strings
                  if (endOfMention.toString().equals(copyOfEndOfMentionText.toString())) {
                      text.setSpan(new DeleteSpan(),
                              spanEnd,
                              copyEnd,
                              Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
                  }
              }
          }
      }
docs: Mark text that was duplicated during text composition to delete it later.
  
  @param text          the given text
  @param cursor        the index of the cursor in text
  @param tokenizer     the {@link Tokenizer} to use