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.

Merge branch 'main' into refine-keybindings

Nate Butler385541372519
diff --cc crates/command_palette2/src/command_palette.rs
index ec77d935612,b0d18c593d8..048749a02d9
--- a/crates/command_palette2/src/command_palette.rs
+++ b/crates/command_palette2/src/command_palette.rs
@@@ -304,19 -301,15 +304,16 @@@ impl PickerDelegate for CommandPaletteD
};
Some(
- ListItem::new(ix)
- .variant(ui::ListItemVariant::Inset)
- .selected(selected)
- .child(
- h_stack()
- .w_full()
- .justify_between()
- .child(HighlightedLabel::new(
- command.name.clone(),
- r#match.positions.clone(),
- ))
- .children(KeyBinding::for_action(&*command.action, cx)),
- ),
+ ListItem::new(ix).inset(true).selected(selected).child(
+ h_stack()
++ .w_full()
+ .justify_between()
+ .child(HighlightedLabel::new(
+ command.name.clone(),
+ r#match.positions.clone(),
+ ))
+ .children(KeyBinding::for_action(&*command.action, cx)),
+ ),
)
}
}
diff --cc crates/ui2/src/components/keybinding.rs
index 15e365e5264,78300ebe54c..d11be1f4fc4
--- a/crates/ui2/src/components/keybinding.rs
+++ b/crates/ui2/src/components/keybinding.rs
@@@ -13,36 -13,20 +13,36 @@@ pub struct KeyBinding
impl RenderOnce for KeyBinding {
type Rendered = Div;
- fn render(self, cx: &mut WindowContext) -> Self::Rendered {
+ fn render(self, _cx: &mut WindowContext) -> Self::Rendered {
- div()
- .flex()
+ h_stack()
+ .flex_none()
.gap_2()
.children(self.key_binding.keystrokes().iter().map(|keystroke| {
- div()
- .flex()
- .gap_1()
+ let key_icon = Self::icon_for_key(&keystroke);
+
+ h_stack()
+ .flex_none()
+ .gap_0p5()
+ .bg(cx.theme().colors().element_background)
+ .p_0p5()
+ .rounded_sm()
.when(keystroke.modifiers.function, |el| el.child(Key::new("fn")))
- .when(keystroke.modifiers.control, |el| el.child(Key::new("^")))
- .when(keystroke.modifiers.alt, |el| el.child(Key::new("⌥")))
- .when(keystroke.modifiers.command, |el| el.child(Key::new("⌘")))
- .when(keystroke.modifiers.shift, |el| el.child(Key::new("⇧")))
- .child(Key::new(keystroke.key.clone()))
+ .when(keystroke.modifiers.control, |el| {
+ el.child(KeyIcon::new(Icon::Control))
+ })
+ .when(keystroke.modifiers.alt, |el| {
+ el.child(KeyIcon::new(Icon::Option))
+ })
+ .when(keystroke.modifiers.command, |el| {
+ el.child(KeyIcon::new(Icon::Command))
+ })
+ .when(keystroke.modifiers.shift, |el| {
+ el.child(KeyIcon::new(Icon::Shift))
+ })
+ // .when_some(key_icon, |el, icon| el.child(KeyIcon::new(icon)))
+ .when(key_icon.is_none(), |el| {
+ el.child(Key::new(keystroke.key.to_uppercase().clone()))
+ })
}))
}
}