History

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

Danilo Leal committed 1 year ago

Commit a960db61 parent 5a0f7961 file · +42 −37Browse files

Unified · Split

crates/keymap_editor/src/keymap_editor.rs+42−37
@@ -26,9 +26,9 @@ use project::{CompletionDisplayOptions, Project}; · 25 unmodified lines
2626 use settings::{BaseKeymap, KeybindSource, KeymapFile, Settings as _, SettingsAssets};
2727 use ui::{
2828 ActiveTheme as _, App, Banner, BorrowAppContext, ContextMenu, IconButtonShape, Indicator,
29− Modal, ModalFooter, ModalHeader, ParentElement as _, Render, Section, SharedString,
30− Styled as _, Table, TableColumnWidths, TableInteractionState, TableResizeBehavior, Tooltip,
31− Window, prelude::*, right_click_menu,
29+ Modal, ModalFooter, ModalHeader, ParentElement as _, PopoverMenu, Render, Section,
30+ SharedString, Styled as _, Table, TableColumnWidths, TableInteractionState,
31+ TableResizeBehavior, Tooltip, Window, prelude::*,
3232 };
3333 use ui_input::SingleLineInput;
3434 use util::ResultExt;
@@ -1663,56 +1663,61 @@ impl Render for KeymapEditor { · 1628 unmodified lines
16631663 }),
16641664 )
16651665 .child(
1666− div()
1667− .ml_1()
1666+ h_flex()
1667+ .w_full()
16681668 .pl_2()
1669− .border_l_1()
1670− .border_color(cx.theme().colors().border_variant)
1669+ .gap_1()
1670+ .justify_end()
16711671 .child(
1672− right_click_menu("open-keymap-menu")
1673− .menu(|window, cx| {
1674− ContextMenu::build(window, cx, |menu, _, _| {
1675− menu.header("Open Keymap JSON")
1676− .action(
1677− "User",
1678− zed_actions::OpenKeymap.boxed_clone(),
1679− )
1672+ PopoverMenu::new("open-keymap-menu")
1673+ .menu(move |window, cx| {
1674+ Some(ContextMenu::build(window, cx, |menu, _, _| {
1675+ menu.header("View Default...")
16801676 .action(
1681− "Zed Default",
1677+ "Zed Key Bindings",
16821678 zed_actions::OpenDefaultKeymap
16831679 .boxed_clone(),
16841680 )
16851681 .action(
1686− "Vim Default",
1682+ "Vim Bindings",
16871683 vim::OpenDefaultKeymap.boxed_clone(),
16881684 )
1689− })
1685+ }))
1686+ })
1687+ .anchor(gpui::Corner::TopRight)
1688+ .offset(gpui::Point {
1689+ x: px(0.0),
1690+ y: px(2.0),
16901691 })
1691− .anchor(gpui::Corner::TopLeft)
1692− .trigger(|open, _, _| {
1692+ .trigger_with_tooltip(
16931693 IconButton::new(
16941694 "OpenKeymapJsonButton",
1695− IconName::Json,
1695+ IconName::Ellipsis,
16961696 )
1697− .icon_size(IconSize::Small)
1698− .when(!open, |this| {
1699− this.tooltip(move |window, cx| {
1700− Tooltip::with_meta(
1701− "Open keymap.json",
1702− Some(&zed_actions::OpenKeymap),
1703− "Right click to view more options",
1697+ .icon_size(IconSize::Small),
1698+ {
1699+ let focus_handle = focus_handle.clone();
1700+ move |window, cx| {
1701+ Tooltip::for_action_in(
1702+ "View Default...",
1703+ &zed_actions::OpenKeymap,
1704+ &focus_handle,
17041705 window,
17051706 cx,
17061707 )
1707− })
1708− })
1709− .on_click(|_, window, cx| {
1710− window.dispatch_action(
1711− zed_actions::OpenKeymap.boxed_clone(),
1712− cx,
1713− );
1714− })
1715− }),
1708+ }
1709+ },
1710+ ),
1711+ )
1712+ .child(
1713+ Button::new("edit-in-json", "Edit in keymap.json")
1714+ .style(ButtonStyle::Outlined)
1715+ .on_click(|_, window, cx| {
1716+ window.dispatch_action(
1717+ zed_actions::OpenKeymap.boxed_clone(),
1718+ cx,
1719+ );
1720+ })
17161721 ),
17171722 )
17181723 ),

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t