RATools icon indicating copy to clipboard operation
RATools copied to clipboard

[Bug] Unicode characters count as two characters and cause cursor misalignment

Open soopercool101 opened this issue 3 years ago • 1 comments

Using unicode characters such as emoji in the text is detected by the editor as two characters and also causes inconsistencies in cursor placement

https://gfycat.com/ScaredPointedCatbird

soopercool101 avatar Mar 03 '21 17:03 soopercool101

It's only emojis that cause this problem. They actually are two characters in Unicode (known as surrogate pairs). While it would be fairly easy to modify the left/right/delete behavior to work with the emoji as a singular character, things get complicated when moving up/down.

Additionally, as you've noted, they also don't play well with the fixed width font. The sample emoji I was testing with (🌎) is 2.3 characters wide. This is also true in Visual Studio. You can see that only three emojis fit in the space of seven characters: image

Interestingly enough, Visual Studio counts each emoji as two characters, but also reports the actual column. When the cursor is after the last globe in the above example, it says I'm at character position 13 (2x6+1), but column 15 (14+1) image

Jamiras avatar Apr 24 '24 23:04 Jamiras