Closed MoritzKn closed 6 years ago
Awesome! Thanks for digging in and investigating this. I think we can probably deal with grapheme clustering in the rendering layer, but you're correct that we don't render those kinds of characters correctly yet anyways.
Attempts to fix #113
Still not perfect: the rust
char
returned bychars()
represent "Unicode Scalar Values" which may not be considered characters 1 to 1:https://stackoverflow.com/questions/46290655/get-the-string-length-in-characters-in-rust
See this demo in the rust play ground
Xray currently displays:
The problem seems to be that the perceived length of a string can't really be determined by the string in isolation. A good example is the
👍🏽
string in the demo: in the editor it is displayed as two separate characters (the skip tone modifier and the actual emoji) but in the output it is displayed as one (the emoji with changed skin tone). As a user I would expect the cursor to move two characters in the first case but one in the second.However since Xray seems to be unable to display complex multibyte unicode characters anyway I'd consider this change to be sufficient for now.