keymap editor: Adjust the "edit in keymap.json" button (#39789)

Making its visuals and positioning more consistent with the same button
in the settings UI.

Release Notes:

- N/A
This commit is contained in:
Danilo Leal
2025-10-08 13:03:15 -03:00
committed by GitHub
parent 5a0f796a44
commit a960db6a43
+42 -37
View File
@@ -26,9 +26,9 @@ use project::{CompletionDisplayOptions, Project};
use settings::{BaseKeymap, KeybindSource, KeymapFile, Settings as _, SettingsAssets}; use settings::{BaseKeymap, KeybindSource, KeymapFile, Settings as _, SettingsAssets};
use ui::{ use ui::{
ActiveTheme as _, App, Banner, BorrowAppContext, ContextMenu, IconButtonShape, Indicator, ActiveTheme as _, App, Banner, BorrowAppContext, ContextMenu, IconButtonShape, Indicator,
Modal, ModalFooter, ModalHeader, ParentElement as _, Render, Section, SharedString, Modal, ModalFooter, ModalHeader, ParentElement as _, PopoverMenu, Render, Section,
Styled as _, Table, TableColumnWidths, TableInteractionState, TableResizeBehavior, Tooltip, SharedString, Styled as _, Table, TableColumnWidths, TableInteractionState,
Window, prelude::*, right_click_menu, TableResizeBehavior, Tooltip, Window, prelude::*,
}; };
use ui_input::SingleLineInput; use ui_input::SingleLineInput;
use util::ResultExt; use util::ResultExt;
@@ -1663,56 +1663,61 @@ impl Render for KeymapEditor {
}), }),
) )
.child( .child(
div() h_flex()
.ml_1() .w_full()
.pl_2() .pl_2()
.border_l_1() .gap_1()
.border_color(cx.theme().colors().border_variant) .justify_end()
.child( .child(
right_click_menu("open-keymap-menu") PopoverMenu::new("open-keymap-menu")
.menu(|window, cx| { .menu(move |window, cx| {
ContextMenu::build(window, cx, |menu, _, _| { Some(ContextMenu::build(window, cx, |menu, _, _| {
menu.header("Open Keymap JSON") menu.header("View Default...")
.action( .action(
"User", "Zed Key Bindings",
zed_actions::OpenKeymap.boxed_clone(),
)
.action(
"Zed Default",
zed_actions::OpenDefaultKeymap zed_actions::OpenDefaultKeymap
.boxed_clone(), .boxed_clone(),
) )
.action( .action(
"Vim Default", "Vim Bindings",
vim::OpenDefaultKeymap.boxed_clone(), vim::OpenDefaultKeymap.boxed_clone(),
) )
}) }))
}) })
.anchor(gpui::Corner::TopLeft) .anchor(gpui::Corner::TopRight)
.trigger(|open, _, _| { .offset(gpui::Point {
x: px(0.0),
y: px(2.0),
})
.trigger_with_tooltip(
IconButton::new( IconButton::new(
"OpenKeymapJsonButton", "OpenKeymapJsonButton",
IconName::Json, IconName::Ellipsis,
) )
.icon_size(IconSize::Small) .icon_size(IconSize::Small),
.when(!open, |this| { {
this.tooltip(move |window, cx| { let focus_handle = focus_handle.clone();
Tooltip::with_meta( move |window, cx| {
"Open keymap.json", Tooltip::for_action_in(
Some(&zed_actions::OpenKeymap), "View Default...",
"Right click to view more options", &zed_actions::OpenKeymap,
&focus_handle,
window, window,
cx, cx,
) )
}) }
}) },
.on_click(|_, window, cx| { ),
window.dispatch_action( )
zed_actions::OpenKeymap.boxed_clone(), .child(
cx, Button::new("edit-in-json", "Edit in keymap.json")
); .style(ButtonStyle::Outlined)
}) .on_click(|_, window, cx| {
}), window.dispatch_action(
zed_actions::OpenKeymap.boxed_clone(),
cx,
);
})
), ),
) )
), ),