[PR #4685] Ensure til::u8u16 still works if the string consists of just a lead byte #25889

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

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

State: closed
Merged: Yes


Summary of the Pull Request

Fixes a flaw that happened if til::u8u16 received a single lead byte.

PR Checklist

Detailed Description of the Pull Request / Additional comments

The loop for caching partials didn't run and thus, the lead byte was
converted to U+FFFD. That's because the loop starts with sequenceLen
initialized with 1. And if the string has a length of 1 the initial
condition is 1<1 which is evaluated to false and the body of the
loop was never executed.

Validation Steps Performed

  1. updated the code of the state class and tested manually that printf "\xE2"; printf "\x98\xBA\n" prints a U+263A character
  2. updated the unit tests to make sure that still up to 3 partials are
    cached
  3. updated the unit tests to make sure caching also works if the string
    consists of a lead byte only
  4. tested manually that #4086 is still resolved
**Original Pull Request:** https://github.com/microsoft/terminal/pull/4685 **State:** closed **Merged:** Yes --- ## Summary of the Pull Request Fixes a flaw that happened if `til::u8u16` received a single lead byte. ## PR Checklist * [x] Closes #4673 * [x] Tests added/passed ## Detailed Description of the Pull Request / Additional comments The loop for caching partials didn't run and thus, the lead byte was converted to U+FFFD. That's because the loop starts with `sequenceLen` initialized with 1. And if the string has a length of 1 the initial condition is `1<1` which is evaluated to `false` and the body of the loop was never executed. ## Validation Steps Performed 1) updated the code of the state class and tested manually that `printf "\xE2"; printf "\x98\xBA\n"` prints a U+263A character 2) updated the unit tests to make sure that still up to 3 partials are cached 3) updated the unit tests to make sure caching also works if the string consists of a lead byte only 4) tested manually that #4086 is still resolved
claunia added the pull-request label 2026-01-31 09:12:27 +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#25889