Skip to content

Commit

Permalink
ui: Fix keybind sizing for non-default UI font sizes (zed-industries#…
Browse files Browse the repository at this point in the history
…24708)

Closes zed-industries#24597 

This fixes the regression from
zed-industries@00971fb
which removed the `text_ui(cx)` - call from the keybinding render. The
removal caused improperly scaled font rendering as shown in the images
below.

This PR reintroduces this behaviour for all cases where `size` is not
set.

| | `main` | With this patch | Parent of
zed-industries@00971fb
| --- | ---- | ---- | --- |
| Small font size (10px) | <img width="204" alt="cur_small"
src="https://github.com/user-attachments/assets/2bb1615a-c346-4da5-855c-01894744ee74"
/> | <img width="205" alt="pr_small"
src="https://github.com/user-attachments/assets/26ab70f0-d6ca-439b-aaea-4d6ded4f8f11"
/> | <img width="203" alt="prev_small"
src="https://github.com/user-attachments/assets/92a04008-8408-4a98-83a2-59fdd6e5708a"
/> |
| Large font size | <img width="369" alt="cur_big"
src="https://github.com/user-attachments/assets/8400c205-19b6-479c-a3d1-df12ed4e84da"
/> | <img width="398" alt="pr_big"
src="https://github.com/user-attachments/assets/01f495aa-0be1-4169-ae09-4292b0e638ff"
/> | <img width="389" alt="prev_big"
src="https://github.com/user-attachments/assets/e041a8ea-a958-4a3b-8fef-0f7fe5079c34"
/> |


Release Notes:

- Fixed keybind hints being improperly scaled for custom ui font sizes
  • Loading branch information
MrSubidubi authored Feb 12, 2025
1 parent cc97f41 commit ea8da43
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion crates/ui/src/components/keybinding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,9 @@ pub struct Key {
impl RenderOnce for Key {
fn render(self, _window: &mut Window, cx: &mut App) -> impl IntoElement {
let single_char = self.key.len() == 1;
let size = self.size.unwrap_or(px(14.).into());
let size = self
.size
.unwrap_or_else(|| TextSize::default().rems(cx).into());

div()
.py_0()
Expand Down

0 comments on commit ea8da43

Please sign in to comment.