From e9c2796034ac9a91d0835bc4b9525727ca58b688 Mon Sep 17 00:00:00 2001 From: Eduardo Alba Date: Tue, 12 Aug 2025 19:09:29 -0400 Subject: [PATCH] Rename 'cycle theme mode' to 'toggle theme mode' and toggle only between light and dark --- crates/theme_selector/src/theme_selector.rs | 16 +++++++++++----- crates/zed/src/zed/app_menus.rs | 4 ++-- crates/zed_actions/src/lib.rs | 4 ++-- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/crates/theme_selector/src/theme_selector.rs b/crates/theme_selector/src/theme_selector.rs index 90606fedc3..ebbda6115f 100644 --- a/crates/theme_selector/src/theme_selector.rs +++ b/crates/theme_selector/src/theme_selector.rs @@ -40,9 +40,9 @@ pub fn init(cx: &mut App) { toggle_icon_theme_selector(workspace, &action, window, cx); }); }); - cx.on_action(|_: &zed_actions::theme_selector::CycleMode, cx| { + cx.on_action(|_: &zed_actions::theme_selector::ToggleMode, cx| { with_active_or_new_workspace(cx, |workspace, window, cx| { - cycle_theme_mode(workspace, window, cx); + toggle_theme_mode(workspace, window, cx); }); }); } @@ -83,15 +83,21 @@ fn toggle_icon_theme_selector( }); } -fn cycle_theme_mode(workspace: &mut Workspace, _window: &mut Window, cx: &mut Context) { +fn toggle_theme_mode(workspace: &mut Workspace, _window: &mut Window, cx: &mut Context) { let current_settings = ThemeSettings::get_global(cx); let current_selection = current_settings.theme_selection.as_ref(); let new_mode = match current_selection { Some(ThemeSelection::Dynamic { mode, .. }) => match mode { ThemeMode::Light => ThemeMode::Dark, - ThemeMode::Dark => ThemeMode::System, - ThemeMode::System => ThemeMode::Light, + ThemeMode::Dark => ThemeMode::Light, + ThemeMode::System => { + if cx.theme().appearance().is_light() { + ThemeMode::Dark + } else { + ThemeMode::Light + } + } }, Some(ThemeSelection::Static(_)) => ThemeMode::Light, None => ThemeMode::Light, diff --git a/crates/zed/src/zed/app_menus.rs b/crates/zed/src/zed/app_menus.rs index bcd2372105..398f35838e 100644 --- a/crates/zed/src/zed/app_menus.rs +++ b/crates/zed/src/zed/app_menus.rs @@ -33,8 +33,8 @@ pub fn app_menus() -> Vec { zed_actions::theme_selector::Toggle::default(), ), MenuItem::action( - "Cycle Theme Mode", - zed_actions::theme_selector::CycleMode, + "Toggle Theme Mode", + zed_actions::theme_selector::ToggleMode, ), ], }), diff --git a/crates/zed_actions/src/lib.rs b/crates/zed_actions/src/lib.rs index 75debcb8f3..c243687b98 100644 --- a/crates/zed_actions/src/lib.rs +++ b/crates/zed_actions/src/lib.rs @@ -244,11 +244,11 @@ pub mod theme_selector { pub themes_filter: Option>, } - /// Cycles between light, dark, and system theme modes. + /// Toggles between light and dark theme modes. #[derive(PartialEq, Clone, Default, Debug, Deserialize, JsonSchema, Action)] #[action(namespace = theme_selector)] #[serde(deny_unknown_fields)] - pub struct CycleMode; + pub struct ToggleMode; } pub mod icon_theme_selector {