serenity icon indicating copy to clipboard operation
serenity copied to clipboard

Emoji: Any country flag emoji turns in to a question mark in a box emoji after pressing backspace.

Open DankDuck09 opened this issue 2 years ago • 9 comments

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

DankDuck09 avatar Sep 16 '22 15:09 DankDuck09

More specifically, these are multi code point emojis, and the backspace press is only deleting the trailing code point.

trflynn89 avatar Sep 18 '22 18:09 trflynn89

Hi! Can I work on this??🇯🇵

oirom avatar Sep 24 '22 05:09 oirom

@oirom of course you can, just try to solve the issue and make a PR once you're ready :^)

MacDue avatar Sep 24 '22 21:09 MacDue

@MacDue Thanks! I will try :)

oirom avatar Sep 25 '22 01:09 oirom

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 avatar Oct 01 '22 17:10 m-bilal-ahmed

@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 avatar Oct 01 '22 23:10 MacDue

@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?

IveGotNorto avatar Oct 02 '22 13:10 IveGotNorto

There probably is not a super trivial fix, I imagine you will need to use LibUnicode to fix this

MacDue avatar Oct 02 '22 14:10 MacDue

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

ftommasi avatar Oct 08 '22 15:10 ftommasi