From bf27edfdee0465971bf5719ae6301fe8e6e1745c Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Tue, 26 Apr 2022 12:08:41 +0200 Subject: [PATCH] Sort themes by light/dark first and then alphabetically --- crates/theme_selector/src/theme_selector.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/crates/theme_selector/src/theme_selector.rs b/crates/theme_selector/src/theme_selector.rs index f1e933774f..5c679be841 100644 --- a/crates/theme_selector/src/theme_selector.rs +++ b/crates/theme_selector/src/theme_selector.rs @@ -36,7 +36,12 @@ impl ThemeSelector { let handle = cx.weak_handle(); let picker = cx.add_view(|cx| Picker::new(handle, cx)); let original_theme = cx.global::().theme.clone(); - let theme_names = registry.list().collect::>(); + let mut theme_names = registry.list().collect::>(); + theme_names.sort_unstable_by(|a, b| { + a.ends_with("dark") + .cmp(&b.ends_with("dark")) + .then_with(|| a.cmp(&b)) + }); let matches = theme_names .iter() .map(|name| StringMatch {