[PR #18300] Unify padding parsers, make SUI operate on struct Thickness #31506

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

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

State: closed
Merged: Yes


The code in #17909 was not completely right for padding values with fewer than four components, and it was doing some fragile string math (that is: if you wanted to change the third element in the padding it would parse out the whole thing, edit the third value, and then format it again).

This pull request moves the control's padding parser into cppwinrt_utils (for lack of a better place) and makes the settings UI use it to parse the padding out into a Thickness as early as possible. Then, the controls operate directly on the Thickness' members rather than parsing the padding string again.

To handle two-way serialization properly, we also required a function that converts a thickness back into a reduced string representation (i.e. when all four values are N, it will return "N").

As a bonus, this pull request also:

  • removes another use of std::getline
  • fixes an issue where resetting the padding would change it (infinitesimally) and cause it to be set again
  • adds a readout of the current padding value in the expander itself
  • removes MaxValueFromPaddingString, which was apparently unused
**Original Pull Request:** https://github.com/microsoft/terminal/pull/18300 **State:** closed **Merged:** Yes --- The code in #17909 was not completely right for padding values with fewer than four components, and it was doing some fragile string math (that is: if you wanted to change the third element in the padding it would parse out the whole thing, edit the third value, and then format it again). This pull request moves the control's padding parser into cppwinrt_utils (for lack of a better place) and makes the settings UI use it to parse the padding out into a `Thickness` as early as possible. Then, the controls operate directly on the Thickness' members rather than parsing the padding string again. To handle two-way serialization properly, we also required a function that converts a thickness back into a reduced string representation (i.e. when all four values are N, it will return "N"). As a bonus, this pull request also: - removes another use of `std::getline` - fixes an issue where resetting the padding would change it (infinitesimally) and cause it to be set again - adds a readout of the current padding value in the expander itself - removes `MaxValueFromPaddingString`, which was apparently unused
claunia added the pull-request label 2026-01-31 09:47: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#31506