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
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -26,9 +26,9 @@ use project::{CompletionDisplayOptions, Project};
use settings::{BaseKeymap, KeybindSource, KeymapFile, Settings as _, SettingsAssets};
use ui::{
ActiveTheme as _, App, Banner, BorrowAppContext, ContextMenu, IconButtonShape, Indicator,
Modal, ModalFooter, ModalHeader, ParentElement as _, Render, Section, SharedString,
Styled as _, Table, TableColumnWidths, TableInteractionState, TableResizeBehavior, Tooltip,
Window, prelude::*, right_click_menu,
Modal, ModalFooter, ModalHeader, ParentElement as _, PopoverMenu, Render, Section,
SharedString, Styled as _, Table, TableColumnWidths, TableInteractionState,
TableResizeBehavior, Tooltip, Window, prelude::*,
};
use ui_input::SingleLineInput;
use util::ResultExt;
@ -1663,56 +1663,61 @@ impl Render for KeymapEditor {
}),
)
.child(
div()
.ml_1()
h_flex()
.w_full()
.pl_2()
.border_l_1()
.border_color(cx.theme().colors().border_variant)
.gap_1()
.justify_end()
.child(
right_click_menu("open-keymap-menu")
.menu(|window, cx| {
ContextMenu::build(window, cx, |menu, _, _| {
menu.header("Open Keymap JSON")
PopoverMenu::new("open-keymap-menu")
.menu(move |window, cx| {
Some(ContextMenu::build(window, cx, |menu, _, _| {
menu.header("View Default...")
.action(
"User",
zed_actions::OpenKeymap.boxed_clone(),
)
.action(
"Zed Default",
"Zed Key Bindings",
zed_actions::OpenDefaultKeymap
.boxed_clone(),
)
.action(
"Vim Default",
"Vim Bindings",
vim::OpenDefaultKeymap.boxed_clone(),
)
})
}))
})
.anchor(gpui::Corner::TopLeft)
.trigger(|open, _, _| {
.anchor(gpui::Corner::TopRight)
.offset(gpui::Point {
x: px(0.0),
y: px(2.0),
})
.trigger_with_tooltip(
IconButton::new(
"OpenKeymapJsonButton",
IconName::Json,
IconName::Ellipsis,
)
.icon_size(IconSize::Small)
.when(!open, |this| {
this.tooltip(move |window, cx| {
Tooltip::with_meta(
"Open keymap.json",
Some(&zed_actions::OpenKeymap),
"Right click to view more options",
.icon_size(IconSize::Small),
{
let focus_handle = focus_handle.clone();
move |window, cx| {
Tooltip::for_action_in(
"View Default...",
&zed_actions::OpenKeymap,
&focus_handle,
window,
cx,
)
})
})
.on_click(|_, window, cx| {
window.dispatch_action(
zed_actions::OpenKeymap.boxed_clone(),
cx,
);
})
}),
}
},
),
)
.child(
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,
);
})
),
)
),