jmacdonald / amp

A complete text editor for your terminal.

Home Page:https://amp.rs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Problems with emoji

nyaa8 opened this issue Β· comments

commented

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 πŸ™‡

commented

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.

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