Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bugs in CharToColumnMapper #16787

Merged
merged 1 commit into from
Feb 29, 2024
Merged

Fix bugs in CharToColumnMapper #16787

merged 1 commit into from
Feb 29, 2024

Conversation

lhecker
Copy link
Member

@lhecker lhecker commented Feb 29, 2024

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.

@lhecker lhecker added Product-Conhost For issues in the Console codebase Area-Output Related to output processing (inserting text into buffer, retrieving buffer text, etc.) Issue-Bug It either shouldn't be doing this or needs an investigation. Priority-1 A description (P1) labels Feb 29, 2024
for (; WI_IsFlagSet(_charOffsets[col], CharOffsetsTrailer); --col)
{
}
currentOffset = _charOffsets[--col];
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI It may be easier to review this code outside of the diff viewer. It's actually only 8 lines of code and a couple comments.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GitHub doesn't even have a side-by-side diff 😆

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does! It's the book symbol here:
image

But for this PR even the side-by-side diff is distracting to read:
image

@DHowett DHowett merged commit 043d5cd into main Feb 29, 2024
20 checks passed
@DHowett DHowett deleted the dev/lhecker/CharToColumnMapper branch February 29, 2024 21:59
DHowett pushed a commit that referenced this pull request Feb 29, 2024
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.

(cherry picked from commit 043d5cd)
Service-Card-Id: 91955569
Service-Version: 1.20
DHowett pushed a commit that referenced this pull request Feb 29, 2024
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.

(cherry picked from commit 043d5cd)
Service-Card-Id: 91955617
Service-Version: 1.19
DHowett pushed a commit that referenced this pull request Feb 29, 2024
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.

(cherry picked from commit 043d5cd)
Service-Card-Id: 91955617
Service-Version: 1.19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Output Related to output processing (inserting text into buffer, retrieving buffer text, etc.) Issue-Bug It either shouldn't be doing this or needs an investigation. Priority-1 A description (P1) Product-Conhost For issues in the Console codebase
Projects
Status: Cherry Picked
Status: To Cherry Pick
Development

Successfully merging this pull request may close these issues.

4 participants