[PR #11888] Use the til::enumset type for the SgrSaveRestoreStackOptions enum #28783

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

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

State: closed
Merged: Yes


Summary of the Pull Request

This replaces the std::bitset for the SgrSaveRestoreStackOptions enum with a til::enumset type, thus avoiding the need to cast the enum to a size_t every time a value is set or tested.

This also fixes an issue with the handling of omitted and zero parameters in the XTPUSHSGR sequence, which are meant to be ignored, and not interpreted as "all".

PR Checklist

Detailed Description of the Pull Request / Additional comments

In addition to dropping all the static_cast operations, the use of the til::enumset also allowed us to get rid of the try/catch handling that was previously required in a couple of places, since the til::enumset operations don't throw.

And to fix the zero parameter handling, we just needed to add an additional lower bound when validating that options are in range - if an option is 0 (All), it will now just be ignored.

Validation Steps Performed

The updated code still passes the existing unit tests, and I've manually confirmed that it fixes the test case for omitted and zero parameters from issue #11883.

**Original Pull Request:** https://github.com/microsoft/terminal/pull/11888 **State:** closed **Merged:** Yes --- ## Summary of the Pull Request This replaces the `std::bitset` for the `SgrSaveRestoreStackOptions` enum with a `til::enumset` type, thus avoiding the need to cast the `enum` to a `size_t` every time a value is set or tested. This also fixes an issue with the handling of omitted and zero parameters in the `XTPUSHSGR` sequence, which are meant to be ignored, and not interpreted as "all". ## PR Checklist * [x] Closes #11879 * [x] Closes #11883 * [x] CLA signed. * [ ] Tests added/passed * [ ] Documentation updated. * [ ] Schema updated. * [ ] I've discussed this with core contributors already. If not checked, I'm ready to accept this work might be rejected in favor of a different grand plan. Issue number where discussion took place: #xxx ## Detailed Description of the Pull Request / Additional comments In addition to dropping all the `static_cast` operations, the use of the `til::enumset` also allowed us to get rid of the `try`/`catch` handling that was previously required in a couple of places, since the `til::enumset` operations don't throw. And to fix the zero parameter handling, we just needed to add an additional lower bound when validating that options are in range - if an option is 0 (`All`), it will now just be ignored. ## Validation Steps Performed The updated code still passes the existing unit tests, and I've manually confirmed that it fixes the test case for omitted and zero parameters from issue #11883.
claunia added the pull-request label 2026-01-31 09:30:42 +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#28783