From ce20e71abfa8721a87e23c33cfaa0cd21be73e10 Mon Sep 17 00:00:00 2001 From: Finn Evers Date: Mon, 13 Oct 2025 12:55:02 +0200 Subject: [PATCH] theme_selector: Fix mouse clicks not updating the theme properly (#40090) Closes https://github.com/zed-industries/zed/issues/40080 Follow-up to https://github.com/zed-industries/zed/pull/39720 We were already doing this for icon themes, but not for normal themes. Issue here is that we would only update the `cx.theme()` on the next frame. On mouse confirmation, we would override the theme and confirm it on the same frame, yet the global would only be peropely updated on the next frame and then instantly reset to the new settings file, which would again be the old theme. This caused a flicker and the selection to not persist.. Keyboard interactions worked still, because there would be a rendered frame inbetween selection and confirmation. Release Notes: - N/A --- crates/theme_selector/src/theme_selector.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/crates/theme_selector/src/theme_selector.rs b/crates/theme_selector/src/theme_selector.rs index d3e21d5bd51613ef496fa9dbea52502688fc1f16..38e7fc33f7b14f198679d0dd541c39cd444a71a3 100644 --- a/crates/theme_selector/src/theme_selector.rs +++ b/crates/theme_selector/src/theme_selector.rs @@ -7,7 +7,7 @@ use gpui::{ Window, actions, }; use picker::{Picker, PickerDelegate}; -use settings::{SettingsStore, update_settings_file}; +use settings::{Settings, SettingsStore, update_settings_file}; use std::sync::Arc; use theme::{Appearance, Theme, ThemeMeta, ThemeRegistry, ThemeSettings}; use ui::{ListItem, ListItemSpacing, prelude::*, v_flex}; @@ -231,12 +231,11 @@ impl PickerDelegate for ThemeSelectorDelegate { ) { self.selection_completed = true; - let theme_name = cx.theme().name.clone(); + let appearance = Appearance::from(window.appearance()); + let theme_name = ThemeSettings::get_global(cx).theme.name(appearance).0; telemetry::event!("Settings Changed", setting = "theme", value = theme_name); - let appearance = Appearance::from(window.appearance()); - update_settings_file(self.fs.clone(), cx, move |settings, _| { theme::set_theme(settings, theme_name.to_string(), appearance); });