History

git_ui: Fix the Git panel commit message editor ignoring `buffer_font_size` (#55233)

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`

Mikhail Pertsev committed 6 months ago

Commit fffd3e51 parent dc5af1d1 file · +46 −23Browse files

Unified · Split

crates/git_ui/src/git_panel.rs+46−23
@@ -37,9 +37,9 @@ use git::{ · 36 unmodified lines
3737 StashApply, StashPop, ToggleFillCommitEditor, TrashUntrackedFiles, UnstageAll,
3838 };
3939 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,
4343 WeakEntity, actions, anchored, deferred, point, size, uniform_list,
4444 };
4545 use itertools::Itertools;
@@ -6158,25 +6158,27 @@ pub fn panel_editor_container(_window: &mut Window, cx: &mut App) -> Div { · 6112 unmodified lines
61586158 pub(crate) fn panel_editor_style(monospace: bool, window: &Window, cx: &App) -> EditorStyle {
61596159 let settings = ThemeSettings::get_global(cx);
61606160
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+ };
61806182
61816183 EditorStyle {
61826184 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
61866188 font_family,
61876189 font_fallbacks,
61886190 font_features,
6189− font_size: TextSize::Small.rems(cx).into(),
6191+ font_size,
61906192 font_weight,
61916193 line_height: line_height.into(),
61926194 ..Default::default()
@@ -8406,4 +8408,25 @@ mod tests { · 2213 unmodified lines
84068408 ));
84078409 });
84088410 }
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+ }
84098432 }