serenity
serenity copied to clipboard
Emoji: Any country flag emoji turns in to a question mark in a box emoji after pressing backspace.
As said in the title of this issue when inserting any country flag emoji and then pressing backspace the emoji turns in to a question mark in a box emoji. EDIT: Also happens with the CatDog face and the all of flag emojis from the SerenityOS tab. The issue is better shown in the attached video.
https://user-images.githubusercontent.com/88255212/190676844-a8965193-7eef-4020-98ea-11d02a4e0f26.mp4
More specifically, these are multi code point emojis, and the backspace press is only deleting the trailing code point.
Hi! Can I work on this??🇯🇵
@oirom of course you can, just try to solve the issue and make a PR once you're ready :^)
@MacDue Thanks! I will try :)
Hey, This seems like an interesting issue to solve. Can you perhaps guide me as to which files I should start looking to make changes?
@m-bilal-ahmed I've not worked in this area but I'd start in something like Userland/Libraries/LibGUI/TextEditor.cpp
and work backwards from there.
@MacDue I've taken a look at this issue and haven't found a trivial solution. It seems that we need to implement the detection for grapheme clusters on backspace, but much of that logic isn't available elsewhere in the project. There is a LibUnicode (specifically CharacterTypes.cpp) library that has some helper methods for doing such a thing. But it looks like ENABLE_UNICODE_DATA needs to be true to compile the needed methods.
Do you have any other advice for making this change?
There probably is not a super trivial fix, I imagine you will need to use LibUnicode to fix this
I took a shot at fixing it. The best thing I could come up with was to look at the previous word (Span of code points after whitespace or start of line) and parsing the whole thing until an emoji was found (or not). I tried doing some research on emoji and I couldn't think of any other way since there is a variable amount of code points for different emoji and its hard to determine if a particular code point is part of an emoji or not. My implementation seems to address the bug, but I am welcome to feedback and suggestions