Helium314/HeliBoard

The Emoji Keyboard Has Grapheme Cluster error

BulkinKing opened this issue ยท 2 comments

**It Does happen in OpenBoard too

Describe the bug
When you Type any Emoji with zero width joiner it handles the most recent emoji correctly but Creates issue in remaining emoji

To Reproduce
Steps to reproduce the behavior:

  1. Go to Emoji Section
  2. Click on People Category
  3. Scroll down to any Family emoji or colored emoji or Flags Category eg:๐Ÿ‘ฉโ€๐Ÿ‘ฉโ€๐Ÿ‘ง๐Ÿ‘ฉโ€๐Ÿ‘ฉโ€๐Ÿ‘งโ€๐Ÿ‘ฆ๐Ÿ‘ฉโ€๐Ÿ‘ฉโ€๐Ÿ‘ฆโ€๐Ÿ‘ฆ๐Ÿ‘‹๐Ÿฟ๐Ÿ‘‹๐Ÿฟ๐Ÿ‡บ๐Ÿ‡ธ๐Ÿ‡ฑ๐Ÿ‡ฐ๐Ÿ‡ฎ๐Ÿ‡ณ it handles the most recent emoji correctly**

Expected behavior
The whole cluster must be removed on backspace pressed the most recent cluster will be removed as in the example ๐Ÿ‘ฉโ€๐Ÿ‘ฉโ€๐Ÿ‘ง๐Ÿ‘ฉโ€๐Ÿ‘ฉโ€๐Ÿ‘งโ€๐Ÿ‘ฆ๐Ÿ‘ฉโ€๐Ÿ‘ฉโ€๐Ÿ‘ฆโ€๐Ÿ‘ฆ๐Ÿ‘‹๐Ÿฟ๐Ÿ‘‹๐Ÿฟ๐Ÿ‡บ๐Ÿ‡ธ๐Ÿ‡ฑ๐Ÿ‡ฐ๐Ÿ‡ฎ๐Ÿ‡ณ the Indian flag will be removed correctly other will create issue on backspace press

Screenshots
If applicable, add screenshots to help explain your problem

Smartphone (please complete the following information):

  • Device: Poco X3/Redmi note 9/Honor 6x
  • OS: 12/12/7

The problem seems to be in https://github.com/Helium314/openboard/blob/aba68b114beead9c11aa939d3098774718af597c/app/src/main/java/org/dslul/openboard/inputmethod/latin/inputlogic/InputLogic.java#L1188-L1190
lengthToDelete is always 2 for emojis, but the actual necessary length may be (much!) more and depends on the emoji.
How to get the correct length? I have no idea...

Using sendDownUpKeyEvent(KeyEvent.KEYCODE_DEL) when pressing delete works, but this causes issues with suggestions.

This is improved with ffe7d81, but may still occur for some emojis, or other characters.
Also it still happens when using delete swipe, as this is char-based (should be fixed in InputLogic).