Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Restore user-defined ordering of profiles (#38665)
Joseph T. Lyonse602cfadd3a2
diff --git a/crates/settings/src/settings_content.rs b/crates/settings/src/settings_content.rsindex 38bff4d6a14..27c0976fb64 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<Box<SettingsContent>>,#[serde(default)]- pub profiles: HashMap<String, SettingsContent>,+ pub profiles: IndexMap<String, SettingsContent>,}pub struct ExtensionsSettingsContent {diff --git a/crates/settings_profile_selector/src/settings_profile_selector.rs b/crates/settings_profile_selector/src/settings_profile_selector.rsindex 0bba83beafb..b2f01cf5c9a 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, "!");+ });+ }}