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

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

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/11888
Author: @j4james
Created: 12/7/2021
Status: Merged
Merged: 12/7/2021
Merged by: @undefined

Base: mainHead: enumset-in-sgrstack


📝 Commits (3)

  • 7555251 Replace bitset with til::enumset in SgrStack.
  • 15514c9 Fix XTPUSHSGR default parameter handling.
  • 7fc047c Fix the #include path format.

📊 Changes

2 files changed (+42 additions, -67 deletions)

View changed files

📝 src/types/inc/sgrStack.hpp (+5 -8)
📝 src/types/sgrStack.cpp (+37 -59)

📄 Description

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.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/microsoft/terminal/pull/11888 **Author:** [@j4james](https://github.com/j4james) **Created:** 12/7/2021 **Status:** ✅ Merged **Merged:** 12/7/2021 **Merged by:** [@undefined](undefined) **Base:** `main` ← **Head:** `enumset-in-sgrstack` --- ### 📝 Commits (3) - [`7555251`](https://github.com/microsoft/terminal/commit/75552511febac785b3d6af64e5c6557fc3a18c56) Replace bitset with til::enumset in SgrStack. - [`15514c9`](https://github.com/microsoft/terminal/commit/15514c98a9483a1e42729704b45dbd20c5957345) Fix XTPUSHSGR default parameter handling. - [`7fc047c`](https://github.com/microsoft/terminal/commit/7fc047cf654f21402569710149835a3c4d15243c) Fix the #include path format. ### 📊 Changes **2 files changed** (+42 additions, -67 deletions) <details> <summary>View changed files</summary> 📝 `src/types/inc/sgrStack.hpp` (+5 -8) 📝 `src/types/sgrStack.cpp` (+37 -59) </details> ### 📄 Description ## 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. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-31 09:30:41 +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#28778