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
26use settings::{BaseKeymap, KeybindSource, KeymapFile, Settings as _, SettingsAssets};26use settings::{BaseKeymap, KeybindSource, KeymapFile, Settings as _, SettingsAssets};
27use ui::{27use ui::{
28 ActiveTheme as _, App, Banner, BorrowAppContext, ContextMenu, IconButtonShape, Indicator,28 ActiveTheme as _, App, Banner, BorrowAppContext, ContextMenu, IconButtonShape, Indicator,
29 Modal, ModalFooter, ModalHeader, ParentElement as _, Render, Section, SharedString,29 Modal, ModalFooter, ModalHeader, ParentElement as _, PopoverMenu, Render, Section,
30 Styled as _, Table, TableColumnWidths, TableInteractionState, TableResizeBehavior, Tooltip,30 SharedString, Styled as _, Table, TableColumnWidths, TableInteractionState,
31 Window, prelude::*, right_click_menu,31 TableResizeBehavior, Tooltip, Window, prelude::*,
32};32};
33use ui_input::SingleLineInput;33use ui_input::SingleLineInput;
34use util::ResultExt;34use util::ResultExt;
@@ -1663,56 +1663,61 @@ impl Render for KeymapEditor { · 1628 unmodified lines
1663 }),1663 }),
1664 )1664 )
1665 .child(1665 .child(
1666 div()1666 h_flex()
1667 .ml_1()1667 .w_full()
1668 .pl_2()1668 .pl_2()
1669 .border_l_1()1669 .gap_1()
1670 .border_color(cx.theme().colors().border_variant)1670 .justify_end()
1671 .child(1671 .child(
1672 right_click_menu("open-keymap-menu")1672 PopoverMenu::new("open-keymap-menu")
1673 .menu(|window, cx| {1673 .menu(move |window, cx| {
1674 ContextMenu::build(window, cx, |menu, _, _| {1674 Some(ContextMenu::build(window, cx, |menu, _, _| {
1675 menu.header("Open Keymap JSON")1675 menu.header("View Default...")
1676 .action(
1677 "User",
1678 zed_actions::OpenKeymap.boxed_clone(),
1679 )
1680 .action(1676 .action(
1681 "Zed Default",1677 "Zed Key Bindings",
1682 zed_actions::OpenDefaultKeymap1678 zed_actions::OpenDefaultKeymap
1683 .boxed_clone(),1679 .boxed_clone(),
1684 )1680 )
1685 .action(1681 .action(
1686 "Vim Default",1682 "Vim Bindings",
1687 vim::OpenDefaultKeymap.boxed_clone(),1683 vim::OpenDefaultKeymap.boxed_clone(),
1688 )1684 )
1689 })1685 }))
1686 })
1687 .anchor(gpui::Corner::TopRight)
1688 .offset(gpui::Point {
1689 x: px(0.0),
1690 y: px(2.0),
1690 })1691 })
1691 .anchor(gpui::Corner::TopLeft)1692 .trigger_with_tooltip(
1692 .trigger(|open, _, _| {
1693 IconButton::new(1693 IconButton::new(
1694 "OpenKeymapJsonButton",1694 "OpenKeymapJsonButton",
1695 IconName::Json,1695 IconName::Ellipsis,
1696 )1696 )
1697 .icon_size(IconSize::Small)1697 .icon_size(IconSize::Small),
1698 .when(!open, |this| {1698 {
1699 this.tooltip(move |window, cx| {1699 let focus_handle = focus_handle.clone();
1700 Tooltip::with_meta(1700 move |window, cx| {
1701 "Open keymap.json",1701 Tooltip::for_action_in(
1702 Some(&zed_actions::OpenKeymap),1702 "View Default...",
1703 "Right click to view more options",1703 &zed_actions::OpenKeymap,
1704 &focus_handle,
1704 window,1705 window,
1705 cx,1706 cx,
1706 )1707 )
1707 })1708 }
1708 })1709 },
1709 .on_click(|_, window, cx| {1710 ),
1710 window.dispatch_action(1711 )
1711 zed_actions::OpenKeymap.boxed_clone(),1712 .child(
1712 cx,1713 Button::new("edit-in-json", "Edit in keymap.json")
1713 );1714 .style(ButtonStyle::Outlined)
1714 })1715 .on_click(|_, window, cx| {
1715 }),1716 window.dispatch_action(
1717 zed_actions::OpenKeymap.boxed_clone(),
1718 cx,
1719 );
1720 })
1716 ),1721 ),
1717 )1722 )
1718 ),1723 ),

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