Helium314 / HeliBoard

Customizable and privacy-conscious open-source keyboard
Apache License 2.0
1.95k stars 71 forks source link

The Emoji Keyboard Has Grapheme Cluster error #22

Open BulkinKing opened 1 year ago

BulkinKing commented 1 year ago

**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):

Helium314 commented 12 months ago

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.

Helium314 commented 10 months ago

This is improved with https://github.com/Helium314/openboard/commit/ffe7d81ebc435f9998c2c61b8f07a01099b3d284, 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).