Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Notify editors on buffer font size changes
Max Brunsfeld8f262892a04f
diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rsindex 288d25f9cd2..ce9c4215cc3 100644--- a/crates/editor/src/editor.rs+++ b/crates/editor/src/editor.rs@@ -97,7 +97,10 @@ use std::{pub use sum_tree::Bias;use sum_tree::TreeMap;use text::{OffsetUtf16, Rope};-use theme::{ActiveTheme, PlayerColor, StatusColors, SyntaxTheme, ThemeColors, ThemeSettings};+use theme::{+ observe_buffer_font_size_adjustment, ActiveTheme, PlayerColor, StatusColors, SyntaxTheme,+ ThemeColors, ThemeSettings,+};use ui::{h_flex, prelude::*, ButtonSize, ButtonStyle, IconButton, IconName, IconSize, ListItem, Popover,Tooltip,@@ -1812,6 +1815,7 @@ impl Editor {cx.observe(&display_map, Self::on_display_map_changed),cx.observe(&blink_manager, |_, _, cx| cx.notify()),cx.observe_global::<SettingsStore>(Self::settings_changed),+ observe_buffer_font_size_adjustment(cx, |_, cx| cx.notify()),cx.observe_window_activation(|editor, cx| {let active = cx.is_window_active();editor.blink_manager.update(cx, |blink_manager, cx| {@@ -8741,6 +8745,7 @@ impl Editor {)),cx,);+ cx.notify();}pub fn set_searchable(&mut self, searchable: bool) {diff --git a/crates/theme/src/settings.rs b/crates/theme/src/settings.rsindex e51ff81b012..efc62ed59c4 100644--- a/crates/theme/src/settings.rs+++ b/crates/theme/src/settings.rs@@ -1,7 +1,9 @@use crate::one_themes::one_dark;use crate::{Theme, ThemeRegistry};use anyhow::Result;-use gpui::{px, AppContext, Font, FontFeatures, FontStyle, FontWeight, Pixels};+use gpui::{+ px, AppContext, Font, FontFeatures, FontStyle, FontWeight, Pixels, Subscription, ViewContext,+};use schemars::{gen::SchemaGenerator,schema::{InstanceType, Schema, SchemaObject},@@ -80,6 +82,13 @@ impl ThemeSettings {}}+pub fn observe_buffer_font_size_adjustment<V: 'static>(+ cx: &mut ViewContext<V>,+ f: impl 'static + Fn(&mut V, &mut ViewContext<V>),+) -> Subscription {+ cx.observe_global::<AdjustedBufferFontSize>(f)+}+pub fn adjusted_font_size(size: Pixels, cx: &mut AppContext) -> Pixels {if let Some(AdjustedBufferFontSize(adjusted_size)) = cx.try_global::<AdjustedBufferFontSize>() {let buffer_font_size = ThemeSettings::get_global(cx).buffer_font_size;