From 5d8fd87953488e5246097a33995eeb0c413473e0 Mon Sep 17 00:00:00 2001 From: Smit Chaudhary Date: Sat, 24 Jan 2026 02:09:13 +0530 Subject: [PATCH] editor: Fix bracket color change when system theme changes (#47505) Closes #47503 I added an observer for `GlobalTheme` changes that check if the accent colors have changed or not. I thought this was closest to the patterns and style in the codebase. I also considered triggering a `SettingsStore` notification on theme reload but that seemed incorrect since the settings didn't really change, even if it would solve the problem (as the editor already observes `SettingsStore` to detect theme changes. Release Notes: - Fixed Bracket color not updating when system theme changes --- crates/editor/src/editor.rs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index 1cd7c01966f787df7bebacb1c188ae8e448a8f7a..dacd00f4d52f0e140f7dfe91e62919fb58d77c3d 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -196,8 +196,8 @@ use std::{ use task::{ResolvedTask, RunnableTag, TaskTemplate, TaskVariables}; use text::{BufferId, FromAnchor, OffsetUtf16, Rope, ToOffset as _}; use theme::{ - AccentColors, ActiveTheme, PlayerColor, StatusColors, SyntaxTheme, Theme, ThemeSettings, - observe_buffer_font_size_adjustment, + AccentColors, ActiveTheme, GlobalTheme, PlayerColor, StatusColors, SyntaxTheme, Theme, + ThemeSettings, observe_buffer_font_size_adjustment, }; use ui::{ Avatar, ButtonSize, ButtonStyle, ContextMenu, Disclosure, IconButton, IconButtonShape, @@ -2488,6 +2488,7 @@ impl Editor { cx.observe_in(&display_map, window, Self::on_display_map_changed), cx.observe(&blink_manager, |_, _, cx| cx.notify()), cx.observe_global_in::(window, Self::settings_changed), + cx.observe_global_in::(window, Self::theme_changed), observe_buffer_font_size_adjustment(cx, |_, cx| cx.notify()), cx.observe_window_activation(window, |editor, window, cx| { let active = window.is_window_active(); @@ -23991,6 +23992,18 @@ impl Editor { cx.notify(); } + fn theme_changed(&mut self, _: &mut Window, cx: &mut Context) { + if !self.mode.is_full() { + return; + } + + let new_accents = self.fetch_accent_data(cx); + if new_accents != self.accent_data { + self.accent_data = new_accents; + self.colorize_brackets(true, cx); + } + } + pub fn set_searchable(&mut self, searchable: bool) { self.searchable = searchable; }