code: private int findSpanEnd(TextCursor cursor, int spanStart, int limit, char span) {
          for (int i = spanStart + 1; i < limit; i++) {
              char c = cursor.text.charAt(i);
              if (c == span) {
                  // Check prev and next symbols
                  if (isGoodAnchor(cursor.text, i + 1) && isNotSymbol(cursor.text, i - 1, span)) {
                      return i + 1;
                  }
              }
          }
          return -1;
      }
docs: Searching for valid formatting span end
  
  @param cursor    text cursor
  @param spanStart expected span start
  @param limit     maximum index in cursor
  @param span      span control character
  @return span end, -1 if not found