linkedin / Hakawai

A powerful, extensible UITextView.
Apache License 2.0
782 stars 115 forks source link

Fix cannot find control char when text length exceeds MAX_MENTION_QUERY_LENGTH #243

Closed krayc425 closed 1 year ago

krayc425 commented 1 year ago
  1. Original text: <-- 200 chars, all attributed -->
  2. When adding a control char: <-- 200 chars, all attributed --> @
  3. Trimmed text: <-- 99 chars, all attributed --> @
  4. Use the trimmed text to find the last unattributed control char in original string:
    <----- 200 chars, all attributed -----> @
    <--- 99 chars ---> @                            <- before fix
                  ⬆️
    <       offset      ><--- 99 chars ---> @       <- after fix
                                       ⬆️

    Now it will think the last control char is attributed, but actually it's not.

Before After
Simulator Screen Recording - iPhone 14 Pro - 2023-02-11 at 04 11 55 Simulator Screen Recording - iPhone 14 Pro - 2023-02-11 at 04 11 00
krayc425 commented 1 year ago

should we lix this change?

Added a config property enableControlCharacterMaxLengthFix, default to YES. Will add a kill switch when integrating w/voyager.

krayc425 commented 1 year ago

/rerun-check "linkedin.Hakawai"