fix: prevent surrogate pairs from being split by the selected range
This is already handled in functions like expandSelectionInDirection which won't select a half of emoji etc. but always the whole surrogate pair. The solution here is the same, if the cursor is placed in the middle of a surrogate pair, it will be moved to the end of the pair. Similarly a selection will either select both or neither.
Hi @jorgemanrubia, could I ask for a code review?
Hi @jorgemanrubia or @flavorjones, is there any chance for this to be reviewed and merged/rejected?
I've rebased this onto current main and verified that the tests pass locally. Code seems find to me. But I'm not sure I understand the problem that's being solved.
@Thomaash can you say a bit more about how this problem occurs in an application -- how is the cursor ending up in the middle of a multi-byte code point?