[PR #8784] Order enum settings according to enum values #27294

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

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

State: closed
Merged: Yes


Sorts the list of EnumEntrys that is used to create combo boxes and
radio buttons in the Settings UI. INITIALIZE_BINDABLE_ENUM_SETTING
sorts the list in increasing order of the enum values, whereas
INITIALIZE_BINDABLE_ENUM_SETTING_REVERSE_ORDER does so in decreasing
order.

References

#6800 - Settings UI Epic

I attempted sorting the IObservableVector<EnumEntry> using
std::sort, but I would get an error in
winrt::Windows::Foundation::swap (C2665). So instead, I did the
following approach:

  • (unchanged) we're converting the IMap from EnumMappings into (1) a
    map of localized strings and (2) the list for XAML controls
  • instead of storing EnumEntrys to the IObservableVector directly,
    store it to a std::vector
  • sort the vector using std::sort
  • now initialize the IObservableVector using the sorted
    std::vector

This uses the value of the associated enum to determine a sorting order.
Since we want the "negative" value (i.e. "none" or "hidden") to be last,
I use EnumEntryComparator and EnumEntryReverseComparator to
determine whether we want increasing or decreasing order respectively.
INITIALIZE_BINDABLE_ENUM_SETTING_REVERSE_ORDER is a copy of
INITIALIZE_BINDABLE_ENUM_SETTING, except it uses
EnumEntryReverseComparator to sort in decreasing order.

Closes #8758

**Original Pull Request:** https://github.com/microsoft/terminal/pull/8784 **State:** closed **Merged:** Yes --- Sorts the list of `EnumEntry`s that is used to create combo boxes and radio buttons in the Settings UI. `INITIALIZE_BINDABLE_ENUM_SETTING` sorts the list in increasing order of the enum values, whereas `INITIALIZE_BINDABLE_ENUM_SETTING_REVERSE_ORDER` does so in decreasing order. ## References #6800 - Settings UI Epic I attempted sorting the `IObservableVector<EnumEntry>` using `std::sort`, but I would get an error in `winrt::Windows::Foundation::swap` (`C2665`). So instead, I did the following approach: - (unchanged) we're converting the `IMap` from EnumMappings into (1) a map of localized strings and (2) the list for XAML controls - instead of storing `EnumEntry`s to the `IObservableVector` directly, store it to a `std::vector` - sort the vector using `std::sort` - _now_ initialize the `IObservableVector` using the sorted `std::vector` This uses the value of the associated enum to determine a sorting order. Since we want the "negative" value (i.e. "none" or "hidden") to be last, I use `EnumEntryComparator` and `EnumEntryReverseComparator` to determine whether we want increasing or decreasing order respectively. `INITIALIZE_BINDABLE_ENUM_SETTING_REVERSE_ORDER` is a copy of `INITIALIZE_BINDABLE_ENUM_SETTING`, except it uses `EnumEntryReverseComparator` to sort in decreasing order. Closes #8758
claunia added the pull-request label 2026-01-31 09:21:10 +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#27294