Skip to content

Fix bugs in CharToColumnMapper - #16787

Merged
Dustin L. Howett (DHowett) merged 1 commit into
mainfrom
dev/lhecker/CharToColumnMapper
Feb 29, 2024
Merged

Dustin L. Howett (DHowett) merged 1 commit into
mainfrom
dev/lhecker/CharToColumnMapper

Conversation

@lhecker

@lhecker Leonard Hecker (lhecker) commented Feb 29, 2024 •

Copy link
Copy Markdown
Member

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 Leonard Hecker (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
Comment thread src/buffer/out/Row.cpp
{
}
currentOffset = _charOffsets[--col];
}

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Dustin L. Howett (DHowett) deleted the dev/lhecker/CharToColumnMapper branch February 29, 2024 21:59
Dustin L. Howett (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
Dustin L. Howett (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
Dustin L. Howett (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

Development

Successfully merging this pull request may close these issues.

4 participants