Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

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

Mikhail Pertsevfffd3e55cb8e
diff --git a/crates/git_ui/src/git_panel.rs b/crates/git_ui/src/git_panel.rs
index d2cc266e0f2..d4cf03c8538 100644
--- a/crates/git_ui/src/git_panel.rs
+++ b/crates/git_ui/src/git_panel.rs
@@ -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)
+ });
+ }
}