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`
This commit is contained in:
Mikhail Pertsev 2026-04-30 13:33:31 +02:00 committed by GitHub
parent dc5af1de64
commit fffd3e55cb
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -37,9 +37,9 @@ use git::{
StashApply, StashPop, ToggleFillCommitEditor, TrashUntrackedFiles, UnstageAll,
};
use gpui::{
Action, Anchor, AsyncApp, AsyncWindowContext, Bounds, ClickEvent, DismissEvent, Empty, Entity,
EventEmitter, FocusHandle, Focusable, KeyContext, MouseButton, MouseDownEvent, Point,
PromptLevel, ScrollStrategy, Subscription, Task, TextStyle, UniformListScrollHandle,
AbsoluteLength, Action, Anchor, AsyncApp, AsyncWindowContext, Bounds, ClickEvent, DismissEvent,
Empty, Entity, EventEmitter, FocusHandle, Focusable, KeyContext, MouseButton, MouseDownEvent,
Point, PromptLevel, ScrollStrategy, Subscription, Task, TextStyle, UniformListScrollHandle,
WeakEntity, actions, anchored, deferred, point, size, uniform_list,
};
use itertools::Itertools;
@ -6158,25 +6158,27 @@ pub fn panel_editor_container(_window: &mut Window, cx: &mut App) -> Div {
pub(crate) fn panel_editor_style(monospace: bool, window: &Window, cx: &App) -> EditorStyle {
let settings = ThemeSettings::get_global(cx);
let font_size = TextSize::Small.rems(cx).to_pixels(window.rem_size());
let (font_family, font_fallbacks, font_features, font_weight, line_height) = if monospace {
(
settings.buffer_font.family.clone(),
settings.buffer_font.fallbacks.clone(),
settings.buffer_font.features.clone(),
settings.buffer_font.weight,
font_size * settings.buffer_line_height.value(),
)
} else {
(
settings.ui_font.family.clone(),
settings.ui_font.fallbacks.clone(),
settings.ui_font.features.clone(),
settings.ui_font.weight,
window.line_height(),
)
};
let (font_family, font_fallbacks, font_features, font_size, font_weight, line_height) =
if monospace {
let font_size = settings.buffer_font_size(cx);
(
settings.buffer_font.family.clone(),
settings.buffer_font.fallbacks.clone(),
settings.buffer_font.features.clone(),
AbsoluteLength::from(font_size),
settings.buffer_font.weight,
font_size * settings.buffer_line_height.value(),
)
} else {
(
settings.ui_font.family.clone(),
settings.ui_font.fallbacks.clone(),
settings.ui_font.features.clone(),
AbsoluteLength::from(TextSize::Small.rems(cx)),
settings.ui_font.weight,
window.line_height(),
)
};
EditorStyle {
background: cx.theme().colors().editor_background,
@ -6186,7 +6188,7 @@ pub(crate) fn panel_editor_style(monospace: bool, window: &Window, cx: &App) ->
font_family,
font_fallbacks,
font_features,
font_size: TextSize::Small.rems(cx).into(),
font_size,
font_weight,
line_height: line_height.into(),
..Default::default()
@ -8406,4 +8408,25 @@ mod tests {
));
});
}
#[gpui::test]
async fn test_panel_editor_style_uses_buffer_font_size(cx: &mut TestAppContext) {
init_test(cx);
cx.update(|cx| {
SettingsStore::update_global(cx, |store, cx| {
store.update_user_settings(cx, |settings| {
settings.theme.buffer_font_size = Some(20.0.into());
});
});
});
cx.add_window(|window, cx| {
let style = panel_editor_style(true, window, cx);
assert_eq!(style.text.font_size.to_pixels(window.rem_size()), px(20.0));
Editor::single_line(window, cx)
});
}
}