From e602cfadd3a27ccd6ed7c3ea865661fd9a978195 Mon Sep 17 00:00:00 2001 From: "Joseph T. Lyons" Date: Mon, 22 Sep 2025 15:35:44 -0400 Subject: [PATCH] Restore user-defined ordering of profiles (#38665) This PR fixes a regression where settings profiles were no longer ordered in the same order that the user defined in their settings. Release Notes: - N/A --- crates/settings/src/settings_content.rs | 4 +- .../src/settings_profile_selector.rs | 38 +++++++++++++++++++ 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/crates/settings/src/settings_content.rs b/crates/settings/src/settings_content.rs index 38bff4d6a1428f017bcd65be3d27e945aebccabd..27c0976fb64dd4ecb473df937cf27f7a21ff3adc 100644 --- a/crates/settings/src/settings_content.rs +++ b/crates/settings/src/settings_content.rs @@ -16,7 +16,7 @@ pub use terminal::*; pub use theme::*; pub use workspace::*; -use collections::HashMap; +use collections::{HashMap, IndexMap}; use gpui::{App, SharedString}; use release_channel::ReleaseChannel; use schemars::JsonSchema; @@ -182,7 +182,7 @@ pub struct UserSettingsContent { pub linux: Option>, #[serde(default)] - pub profiles: HashMap, + pub profiles: IndexMap, } pub struct ExtensionsSettingsContent { diff --git a/crates/settings_profile_selector/src/settings_profile_selector.rs b/crates/settings_profile_selector/src/settings_profile_selector.rs index 0bba83beafb2ddc1c20767aefd15cc2095ca71ba..b2f01cf5c9a2b759eee3988762e43f07efc6952d 100644 --- a/crates/settings_profile_selector/src/settings_profile_selector.rs +++ b/crates/settings_profile_selector/src/settings_profile_selector.rs @@ -578,4 +578,42 @@ mod tests { assert_eq!(ThemeSettings::get_global(cx).buffer_font_size(cx).0, 10.0); }); } + + #[gpui::test] + async fn test_settings_profile_selector_is_in_user_configuration_order( + cx: &mut TestAppContext, + ) { + // Must be unique names (HashMap) + let profiles_json = json!({ + "z": {}, + "e": {}, + "d": {}, + " ": {}, + "r": {}, + "u": {}, + "l": {}, + "3": {}, + "s": {}, + "!": {}, + }); + let (workspace, cx) = init_test(profiles_json.clone(), cx).await; + + cx.dispatch_action(settings_profile_selector::Toggle); + let picker = active_settings_profile_picker(&workspace, cx); + + picker.read_with(cx, |picker, _| { + assert_eq!(picker.delegate.matches.len(), 11); + assert_eq!(picker.delegate.matches[0].string, display_name(&None)); + assert_eq!(picker.delegate.matches[1].string, "z"); + assert_eq!(picker.delegate.matches[2].string, "e"); + assert_eq!(picker.delegate.matches[3].string, "d"); + assert_eq!(picker.delegate.matches[4].string, " "); + assert_eq!(picker.delegate.matches[5].string, "r"); + assert_eq!(picker.delegate.matches[6].string, "u"); + assert_eq!(picker.delegate.matches[7].string, "l"); + assert_eq!(picker.delegate.matches[8].string, "3"); + assert_eq!(picker.delegate.matches[9].string, "s"); + assert_eq!(picker.delegate.matches[10].string, "!"); + }); + } }