amp icon indicating copy to clipboard operation
amp copied to clipboard

Problems with emoji

Open nyaa8 opened this issue 4 years ago • 2 comments

Hello! I've noticed that when placing the cursor after an emoji in Insert mode, Amp breaks a bit :/

Here is a GIF: result

Amp probably gets confused with emoji's structure 😕

Some random stuff related to emoji encoding

JavaScript

Values Values and mixes

🐛

The first character is called Replacement Character and the second one is a part of Low Surrogates block 🤔

🍙

Again, the first one belongs to High Surrogates, and the second one to Low Surrogates.


Then I decided to check it in Rust: Rust

Here is the code I used: gist.github.com/nyaascii/65eccc68c388cf21ed8b270e774d386d

Sorry and thank you for reading this 🙇

nyaa8 avatar Jun 07 '20 00:06 nyaa8

I am a newbie to Rust, so I might be wrong.

It looks like the problem is with the frontend(?) because the file looks correctly in Vim after saving in Amp.

nyaa8 avatar Jun 07 '20 00:06 nyaa8

It seems like emojis or grapheme clusters of width 2 isn't counted as such and therefor the cursor position is wrong. Look into Unicode's EastAsianWidth.txt doc on how to determine this, also need to check for VS16, amongst other things (this specification for a python wcwidth library might help) .. or use a existing library which solves these things. Similar to zigglyph

erf avatar Jan 24 '24 00:01 erf