jmacdonald / amp

A complete text editor for your terminal.
https://amp.rs
Other
3.75k stars 106 forks source link

Problems with emoji #194

Open nyaa8 opened 4 years ago

nyaa8 commented 4 years ago

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 commented 4 years ago

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.

erf commented 10 months ago

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