Skip to content

Comments

fix: prevent surrogate pairs from being split by the selected range#1226

Open
Thomaash wants to merge 1 commit intobasecamp:mainfrom
Thomaash:main
Open

fix: prevent surrogate pairs from being split by the selected range#1226
Thomaash wants to merge 1 commit intobasecamp:mainfrom
Thomaash:main

Conversation

@Thomaash
Copy link
Contributor

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.

@Thomaash
Copy link
Contributor Author

Hi @jorgemanrubia, could I ask for a code review?

@Thomaash
Copy link
Contributor Author

Hi @jorgemanrubia or @flavorjones, is there any chance for this to be reviewed and merged/rejected?

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.
@flavorjones
Copy link
Member

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants