Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Right-align key bindings in context menus
Max Brunsfeld77acba9e4c59
diff --git a/crates/ui2/src/components/context_menu.rs b/crates/ui2/src/components/context_menu.rsindex b5ef8cf1608..29d8af54a7b 100644--- a/crates/ui2/src/components/context_menu.rs+++ b/crates/ui2/src/components/context_menu.rs@@ -1,4 +1,6 @@-use crate::{prelude::*, v_stack, KeyBinding, Label, List, ListItem, ListSeparator, ListSubHeader};+use crate::{+ h_stack, prelude::*, v_stack, KeyBinding, Label, List, ListItem, ListSeparator, ListSubHeader,+};use gpui::{overlay, px, Action, AnchorCorner, AnyElement, AppContext, Bounds, ClickEvent, DismissEvent,DispatchPhase, Div, EventEmitter, FocusHandle, FocusableView, IntoElement, LayoutId,@@ -129,8 +131,17 @@ impl Render for ContextMenu {let dismiss = cx.listener(|_, _, cx| cx.emit(DismissEvent::Dismiss));ListItem::new(entry.clone())- .child(Label::new(entry.clone()))- .children(key_binding.clone())+ .child(+ h_stack()+ .w_full()+ .justify_between()+ .child(Label::new(entry.clone()))+ .children(+ key_binding+ .clone()+ .map(|binding| div().ml_1().child(binding)),+ ),+ ).on_click(move |event, cx| {callback(event, cx);dismiss(event, cx)diff --git a/crates/ui2/src/components/list.rs b/crates/ui2/src/components/list.rsindex 749de951d9a..fd801b7393c 100644--- a/crates/ui2/src/components/list.rs+++ b/crates/ui2/src/components/list.rs@@ -362,17 +362,15 @@ impl RenderOnce for List {type Rendered = Div;fn render(self, _cx: &mut WindowContext) -> Self::Rendered {- let list_content = match (self.children.is_empty(), self.toggle) {- (false, _) => div().children(self.children),- (true, Toggle::Toggled(false)) => div(),- (true, _) => div().child(Label::new(self.empty_message.clone()).color(Color::Muted)),- };-v_stack().w_full().py_1().children(self.header.map(|header| header))- .child(list_content)+ .map(|this| match (self.children.is_empty(), self.toggle) {+ (false, _) => this.children(self.children),+ (true, Toggle::Toggled(false)) => this,+ (true, _) => this.child(Label::new(self.empty_message.clone()).color(Color::Muted)),+ })}}