Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle emoji correctly when deleting text #1169

Merged
merged 1 commit into from
Dec 2, 2024

Conversation

gitterrost4
Copy link
Contributor

We expand last-character-detection to handle emoji (especially those connected by zero-width-joiners such as families with different skin tones) correctly when hitting the backspace key.

Fixes #1168

@dessalines
Copy link
Owner

Could you link where you got this from? It's kind of weird to me to have so much custom code with exceptions for a delete key.

@gitterrost4
Copy link
Contributor Author

I basically just read up on how to handle unicode sequences on android:

https://developer.android.com/reference/android/icu/text/BreakIterator

Also here is a cautionary sentence in the documentation of deleteSurroundingText and right below it is the documentation of deleteSurroundingTextInCodePoints, which would make the code a lot simpler, but is only available from API 24:

https://developer.android.com/reference/android/view/inputmethod/InputConnection#deleteSurroundingText(int,%20int)

@dessalines
Copy link
Owner

Deleting a key is such a simple action, that I'd rather see how other keyboards are doing it before custom-coding something from scratch.

@gitterrost4
Copy link
Contributor Author

I looked at florisboard in detail, but it's a lot more involved there.

@dessalines
Copy link
Owner

Looks like AnySoftKey sends delete events: https://github.com/AnySoftKeyboard/AnySoftKeyboard/blob/d1edc81ede3bc946740462ae40d33774e8bd3d95/ime/app/src/main/java/com/anysoftkeyboard/AnySoftKeyboard.java#L891

I'm still not sure whether we should be doing these complicated hacks to do something as simple as deleting a key, just because a few applications improperly hijack key events. I'll merge for now, but if this causes more problems and more complication down the road, then I'm going to switch back to a simple delete keyevent, and ask people to open up issues on those applications.

@dessalines dessalines merged commit 550a0ee into dessalines:main Dec 2, 2024
1 check passed
@gitterrost4
Copy link
Contributor Author

Anysoft also only sends the del key in specific circumstances. If you look at line 913, it also does some calculation with code points.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Emojis need to press backspace twice to remove
2 participants