[PR #4731] Avoid splitting surrogate pairs when breaking runs for scaling #25918

Open
opened 2026-01-31 09:12:37 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/microsoft/terminal/pull/4731

State: closed
Merged: Yes


Summary of the Pull Request

  • Surrogate pairs are being split in half with the run splitting check.

References

  • Related to #4708 but not going to fix it.

PR Checklist

Detailed Description of the Pull Request / Additional comments

  • The adjustment of the run heights in the correction function reports back a text index and a scaling factor. However, I didn't remember at the time that the text is being stored as UTF-16. So the index given can be pointing to the high surrogate of a pair. Thus adding 1 to split "after" the text character, then backing up by 1 isn't valid in if the index given was for a high surrogate.

The quick fix is to advance by two if it's a high surrogate and one otherwise.

Validation Steps Performed

  • Used the sample code from #4704 to print the house emoji in various situations into the buffer.
**Original Pull Request:** https://github.com/microsoft/terminal/pull/4731 **State:** closed **Merged:** Yes --- ## Summary of the Pull Request - Surrogate pairs are being split in half with the run splitting check. ## References - Related to #4708 but not going to fix it. ## PR Checklist * [x] Closes #4704 * [x] I work here. * [x] I am a core contributor. ## Detailed Description of the Pull Request / Additional comments - The adjustment of the run heights in the correction function reports back a text index and a scaling factor. However, I didn't remember at the time that the text is being stored as UTF-16. So the index given can be pointing to the high surrogate of a pair. Thus adding 1 to split "after" the text character, then backing up by 1 isn't valid in if the index given was for a high surrogate. The quick fix is to advance by two if it's a high surrogate and one otherwise. ## Validation Steps Performed - Used the sample code from #4704 to print the house emoji in various situations into the buffer.
claunia added the pull-request label 2026-01-31 09:12:37 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#25918