Closes #55227 Updates the Git panel commit message editor to respect the configured `buffer_font_size` when using buffer/editor typography. This keeps the commit box visually consistent with other editor text while preserving the existing UI-font sizing path for non-buffer panel editor styles. Self-Review Checklist: - [x] I've reviewed my own diff for quality, security, and reliability - [x] Unsafe blocks (if any) have justifying comments - [x] The content is consistent with the [UI/UX checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) - [x] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable Release Notes: - Fixed the Git panel commit message editor ignoring `buffer_font_size`
Unified · Split
| @@ -37,9 +37,9 @@ use git::{ · 36 unmodified lines | ||
| 37 | 37 | StashApply, StashPop, ToggleFillCommitEditor, TrashUntrackedFiles, UnstageAll, |
| 38 | 38 | }; |
| 39 | 39 | use gpui::{ |
| 40 | − Action, Anchor, AsyncApp, AsyncWindowContext, Bounds, ClickEvent, DismissEvent, Empty, Entity, | |
| 41 | − EventEmitter, FocusHandle, Focusable, KeyContext, MouseButton, MouseDownEvent, Point, | |
| 42 | − PromptLevel, ScrollStrategy, Subscription, Task, TextStyle, UniformListScrollHandle, | |
| 40 | + AbsoluteLength, Action, Anchor, AsyncApp, AsyncWindowContext, Bounds, ClickEvent, DismissEvent, | |
| 41 | + Empty, Entity, EventEmitter, FocusHandle, Focusable, KeyContext, MouseButton, MouseDownEvent, | |
| 42 | + Point, PromptLevel, ScrollStrategy, Subscription, Task, TextStyle, UniformListScrollHandle, | |
| 43 | 43 | WeakEntity, actions, anchored, deferred, point, size, uniform_list, |
| 44 | 44 | }; |
| 45 | 45 | use itertools::Itertools; |
| @@ -6158,25 +6158,27 @@ pub fn panel_editor_container(_window: &mut Window, cx: &mut App) -> Div { · 6112 unmodified lines | ||
| 6158 | 6158 | pub(crate) fn panel_editor_style(monospace: bool, window: &Window, cx: &App) -> EditorStyle { |
| 6159 | 6159 | let settings = ThemeSettings::get_global(cx); |
| 6160 | 6160 | |
| 6161 | − let font_size = TextSize::Small.rems(cx).to_pixels(window.rem_size()); | |
| 6162 | − | |
| 6163 | − let (font_family, font_fallbacks, font_features, font_weight, line_height) = if monospace { | |
| 6164 | − ( | |
| 6165 | − settings.buffer_font.family.clone(), | |
| 6166 | − settings.buffer_font.fallbacks.clone(), | |
| 6167 | − settings.buffer_font.features.clone(), | |
| 6168 | − settings.buffer_font.weight, | |
| 6169 | − font_size * settings.buffer_line_height.value(), | |
| 6170 | − ) | |
| 6171 | − } else { | |
| 6172 | − ( | |
| 6173 | − settings.ui_font.family.clone(), | |
| 6174 | − settings.ui_font.fallbacks.clone(), | |
| 6175 | − settings.ui_font.features.clone(), | |
| 6176 | − settings.ui_font.weight, | |
| 6177 | − window.line_height(), | |
| 6178 | − ) | |
| 6179 | − }; | |
| 6161 | + let (font_family, font_fallbacks, font_features, font_size, font_weight, line_height) = | |
| 6162 | + if monospace { | |
| 6163 | + let font_size = settings.buffer_font_size(cx); | |
| 6164 | + ( | |
| 6165 | + settings.buffer_font.family.clone(), | |
| 6166 | + settings.buffer_font.fallbacks.clone(), | |
| 6167 | + settings.buffer_font.features.clone(), | |
| 6168 | + AbsoluteLength::from(font_size), | |
| 6169 | + settings.buffer_font.weight, | |
| 6170 | + font_size * settings.buffer_line_height.value(), | |
| 6171 | + ) | |
| 6172 | + } else { | |
| 6173 | + ( | |
| 6174 | + settings.ui_font.family.clone(), | |
| 6175 | + settings.ui_font.fallbacks.clone(), | |
| 6176 | + settings.ui_font.features.clone(), | |
| 6177 | + AbsoluteLength::from(TextSize::Small.rems(cx)), | |
| 6178 | + settings.ui_font.weight, | |
| 6179 | + window.line_height(), | |
| 6180 | + ) | |
| 6181 | + }; | |
| 6180 | 6182 | |
| 6181 | 6183 | EditorStyle { |
| 6182 | 6184 | background: cx.theme().colors().editor_background, |
| @@ -6186,7 +6188,7 @@ pub(crate) fn panel_editor_style(monospace: bool, window: &Window, cx: &App) -> · 3 unmodified lines | ||
| 6186 | 6188 | font_family, |
| 6187 | 6189 | font_fallbacks, |
| 6188 | 6190 | font_features, |
| 6189 | − font_size: TextSize::Small.rems(cx).into(), | |
| 6191 | + font_size, | |
| 6190 | 6192 | font_weight, |
| 6191 | 6193 | line_height: line_height.into(), |
| 6192 | 6194 | ..Default::default() |
| @@ -8406,4 +8408,25 @@ mod tests { · 2213 unmodified lines | ||
| 8406 | 8408 | )); |
| 8407 | 8409 | }); |
| 8408 | 8410 | } |
| 8411 | + | |
| 8412 | + #[gpui::test] | |
| 8413 | + async fn test_panel_editor_style_uses_buffer_font_size(cx: &mut TestAppContext) { | |
| 8414 | + init_test(cx); | |
| 8415 | + | |
| 8416 | + cx.update(|cx| { | |
| 8417 | + SettingsStore::update_global(cx, |store, cx| { | |
| 8418 | + store.update_user_settings(cx, |settings| { | |
| 8419 | + settings.theme.buffer_font_size = Some(20.0.into()); | |
| 8420 | + }); | |
| 8421 | + }); | |
| 8422 | + }); | |
| 8423 | + | |
| 8424 | + cx.add_window(|window, cx| { | |
| 8425 | + let style = panel_editor_style(true, window, cx); | |
| 8426 | + | |
| 8427 | + assert_eq!(style.text.font_size.to_pixels(window.rem_size()), px(20.0)); | |
| 8428 | + | |
| 8429 | + Editor::single_line(window, cx) | |
| 8430 | + }); | |
| 8431 | + } | |
| 8409 | 8432 | } |