[PR #4125] Correct passthrough sequences after refactor #25656

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

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

State: closed
Merged: Yes


Summary of the Pull Request

When refactoring the StateMachine::ProcessString algorithm to use safer structures, I made an off-by-one error when attempting to simplify the loop.

References

PR Checklist

Detailed Description of the Pull Request / Additional comments

The algorithm in use exploited holding onto some pointers and sizes as it rotated around the loop to call back as member variables in the pass-through function FlushToTerminal.

As a part of the refactor, I adjusted to persisting a std::wstring_view of the currently processing string instead of pointer/size. I also attempted to simplify the loop at the same time as both the individual and group branches were performing some redundant operations in respect to updating the "run" length.

Turns out, I made a mistake here. I wrote it so it worked correctly for the bottom half where we transition from bulk printing to an escape but then I messed up the top case.

Validation Steps Performed

  • Manual validation of the exact command given in the bug report.
  • Wrote automated tests to validate both paths through the ProcessString loop that work with the _run variable.
**Original Pull Request:** https://github.com/microsoft/terminal/pull/4125 **State:** closed **Merged:** Yes --- ## Summary of the Pull Request When refactoring the `StateMachine::ProcessString` algorithm to use safer structures, I made an off-by-one error when attempting to simplify the loop. ## References - Introduced in #3956 ## PR Checklist * [x] Closes #4116 * [x] I work here. * [x] Tests added/passed * [x] No documentation * [x] I'm a core contributor. ## Detailed Description of the Pull Request / Additional comments The algorithm in use exploited holding onto some pointers and sizes as it rotated around the loop to call back as member variables in the pass-through function `FlushToTerminal`. As a part of the refactor, I adjusted to persisting a `std::wstring_view` of the currently processing string instead of pointer/size. I also attempted to simplify the loop at the same time as both the individual and group branches were performing some redundant operations in respect to updating the "run" length. Turns out, I made a mistake here. I wrote it so it worked correctly for the bottom half where we transition from bulk printing to an escape but then I messed up the top case. ## Validation Steps Performed - [x] Manual validation of the exact command given in the bug report. - [x] Wrote automated tests to validate both paths through the `ProcessString` loop that work with the `_run` variable.
claunia added the pull-request label 2026-01-31 09:10:55 +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#25656