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
This commit is contained in:
Finn Evers
2025-10-13 10:55:02 +00:00
committed by GitHub
parent 237474a889
commit ce20e71abf
+3 -4
View File
@@ -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);
});