[PR #16787] Fix bugs in CharToColumnMapper #30994

Closed
opened 2026-01-31 09:44:25 +00:00 by claunia · 0 comments
Owner

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

State: closed
Merged: Yes


Aside from overall simplifying CharToColumnMapper this fixes 2 bugs:

  • The backward search loop may have iterated 1 column too far,
    because it didn't stop at *current <= *target, but rather at
    *(current - 1) <= *target. This issue was only apparent when
    surrogate pairs were being used in a row.
  • When the target offset is that of a trailing surrogate pair
    the forward search loop may have iterated 1 column too far.
    It's somewhat unlikely for this to happen since this code is
    only used through ICU, but you never know.

This is a continuation of PR #16775.

**Original Pull Request:** https://github.com/microsoft/terminal/pull/16787 **State:** closed **Merged:** Yes --- Aside from overall simplifying `CharToColumnMapper` this fixes 2 bugs: * The backward search loop may have iterated 1 column too far, because it didn't stop at `*current <= *target`, but rather at `*(current - 1) <= *target`. This issue was only apparent when surrogate pairs were being used in a row. * When the target offset is that of a trailing surrogate pair the forward search loop may have iterated 1 column too far. It's somewhat unlikely for this to happen since this code is only used through ICU, but you never know. This is a continuation of PR #16775.
claunia added the pull-request label 2026-01-31 09:44:25 +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#30994