crates/keymap_editor/src/keymap_editor.rs π
@@ -1576,33 +1576,6 @@ impl Render for KeymapEditor {
.child(
h_flex()
.gap_2()
- .child(
- right_click_menu("open-keymap-menu")
- .menu(|window, cx| {
- ContextMenu::build(window, cx, |menu, _, _| {
- menu.header("Open Keymap JSON")
- .action("User", zed_actions::OpenKeymap.boxed_clone())
- .action("Zed Default", zed_actions::OpenDefaultKeymap.boxed_clone())
- .action("Vim Default", vim::OpenDefaultKeymap.boxed_clone())
- })
- })
- .anchor(gpui::Corner::TopLeft)
- .trigger(|open, _, _|
- IconButton::new(
- "OpenKeymapJsonButton",
- IconName::Json
- )
- .shape(ui::IconButtonShape::Square)
- .when(!open, |this|
- this.tooltip(move |window, cx| {
- Tooltip::with_meta("Open Keymap JSON", Some(&zed_actions::OpenKeymap),"Right click to view more options", window, cx)
- })
- )
- .on_click(|_, window, cx| {
- window.dispatch_action(zed_actions::OpenKeymap.boxed_clone(), cx);
- })
- )
- )
.child(
div()
.key_context({
@@ -1617,73 +1590,139 @@ impl Render for KeymapEditor {
.py_1()
.border_1()
.border_color(theme.colors().border)
- .rounded_lg()
+ .rounded_md()
.child(self.filter_editor.clone()),
)
.child(
- IconButton::new(
- "KeymapEditorToggleFiltersIcon",
- IconName::Keyboard,
- )
- .shape(ui::IconButtonShape::Square)
- .tooltip({
- let focus_handle = focus_handle.clone();
-
- move |window, cx| {
- Tooltip::for_action_in(
- "Search by Keystroke",
- &ToggleKeystrokeSearch,
- &focus_handle.clone(),
- window,
- cx,
+ h_flex()
+ .gap_1()
+ .min_w_64()
+ .child(
+ IconButton::new(
+ "KeymapEditorToggleFiltersIcon",
+ IconName::Keyboard,
)
- }
- })
- .toggle_state(matches!(
- self.search_mode,
- SearchMode::KeyStroke { .. }
- ))
- .on_click(|_, window, cx| {
- window.dispatch_action(ToggleKeystrokeSearch.boxed_clone(), cx);
- }),
- )
- .child(
- IconButton::new("KeymapEditorConflictIcon", IconName::Warning)
- .shape(ui::IconButtonShape::Square)
- .when(
- self.keybinding_conflict_state.any_user_binding_conflicts(),
- |this| {
- this.indicator(Indicator::dot().color(Color::Warning))
- },
+ .icon_size(IconSize::Small)
+ .tooltip({
+ let focus_handle = focus_handle.clone();
+
+ move |window, cx| {
+ Tooltip::for_action_in(
+ "Search by Keystroke",
+ &ToggleKeystrokeSearch,
+ &focus_handle.clone(),
+ window,
+ cx,
+ )
+ }
+ })
+ .toggle_state(matches!(
+ self.search_mode,
+ SearchMode::KeyStroke { .. }
+ ))
+ .on_click(|_, window, cx| {
+ window.dispatch_action(
+ ToggleKeystrokeSearch.boxed_clone(),
+ cx,
+ );
+ }),
)
- .tooltip({
- let filter_state = self.filter_state;
- let focus_handle = focus_handle.clone();
-
- move |window, cx| {
- Tooltip::for_action_in(
- match filter_state {
- FilterState::All => "Show Conflicts",
- FilterState::Conflicts => "Hide Conflicts",
+ .child(
+ IconButton::new("KeymapEditorConflictIcon", IconName::Warning)
+ .icon_size(IconSize::Small)
+ .when(
+ self.keybinding_conflict_state
+ .any_user_binding_conflicts(),
+ |this| {
+ this.indicator(
+ Indicator::dot().color(Color::Warning),
+ )
},
- &ToggleConflictFilter,
- &focus_handle.clone(),
- window,
- cx,
)
- }
- })
- .selected_icon_color(Color::Warning)
- .toggle_state(matches!(
- self.filter_state,
- FilterState::Conflicts
- ))
- .on_click(|_, window, cx| {
- window.dispatch_action(
- ToggleConflictFilter.boxed_clone(),
- cx,
- );
- }),
+ .tooltip({
+ let filter_state = self.filter_state;
+ let focus_handle = focus_handle.clone();
+
+ move |window, cx| {
+ Tooltip::for_action_in(
+ match filter_state {
+ FilterState::All => "Show Conflicts",
+ FilterState::Conflicts => {
+ "Hide Conflicts"
+ }
+ },
+ &ToggleConflictFilter,
+ &focus_handle.clone(),
+ window,
+ cx,
+ )
+ }
+ })
+ .selected_icon_color(Color::Warning)
+ .toggle_state(matches!(
+ self.filter_state,
+ FilterState::Conflicts
+ ))
+ .on_click(|_, window, cx| {
+ window.dispatch_action(
+ ToggleConflictFilter.boxed_clone(),
+ cx,
+ );
+ }),
+ )
+ .child(
+ div()
+ .ml_1()
+ .pl_2()
+ .border_l_1()
+ .border_color(cx.theme().colors().border_variant)
+ .child(
+ right_click_menu("open-keymap-menu")
+ .menu(|window, cx| {
+ ContextMenu::build(window, cx, |menu, _, _| {
+ menu.header("Open Keymap JSON")
+ .action(
+ "User",
+ zed_actions::OpenKeymap.boxed_clone(),
+ )
+ .action(
+ "Zed Default",
+ zed_actions::OpenDefaultKeymap
+ .boxed_clone(),
+ )
+ .action(
+ "Vim Default",
+ vim::OpenDefaultKeymap.boxed_clone(),
+ )
+ })
+ })
+ .anchor(gpui::Corner::TopLeft)
+ .trigger(|open, _, _| {
+ IconButton::new(
+ "OpenKeymapJsonButton",
+ IconName::Json,
+ )
+ .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",
+ window,
+ cx,
+ )
+ })
+ })
+ .on_click(|_, window, cx| {
+ window.dispatch_action(
+ zed_actions::OpenKeymap.boxed_clone(),
+ cx,
+ );
+ })
+ }),
+ ),
+ )
),
)
.when_some(
@@ -1694,48 +1733,42 @@ impl Render for KeymapEditor {
|this, exact_match| {
this.child(
h_flex()
- .map(|this| {
- if self
- .keybinding_conflict_state
- .any_user_binding_conflicts()
- {
- this.pr(rems_from_px(54.))
- } else {
- this.pr_7()
- }
- })
.gap_2()
.child(self.keystroke_editor.clone())
.child(
- IconButton::new(
- "keystrokes-exact-match",
- IconName::CaseSensitive,
- )
- .tooltip({
- let keystroke_focus_handle =
- self.keystroke_editor.read(cx).focus_handle(cx);
-
- move |window, cx| {
- Tooltip::for_action_in(
- "Toggle Exact Match Mode",
- &ToggleExactKeystrokeMatching,
- &keystroke_focus_handle,
- window,
- cx,
+ h_flex()
+ .min_w_64()
+ .child(
+ IconButton::new(
+ "keystrokes-exact-match",
+ IconName::CaseSensitive,
)
- }
- })
- .shape(IconButtonShape::Square)
- .toggle_state(exact_match)
- .on_click(
- cx.listener(|_, _, window, cx| {
- window.dispatch_action(
- ToggleExactKeystrokeMatching.boxed_clone(),
- cx,
- );
- }),
- ),
- ),
+ .tooltip({
+ let keystroke_focus_handle =
+ self.keystroke_editor.read(cx).focus_handle(cx);
+
+ move |window, cx| {
+ Tooltip::for_action_in(
+ "Toggle Exact Match Mode",
+ &ToggleExactKeystrokeMatching,
+ &keystroke_focus_handle,
+ window,
+ cx,
+ )
+ }
+ })
+ .shape(IconButtonShape::Square)
+ .toggle_state(exact_match)
+ .on_click(
+ cx.listener(|_, _, window, cx| {
+ window.dispatch_action(
+ ToggleExactKeystrokeMatching.boxed_clone(),
+ cx,
+ );
+ }),
+ ),
+ ),
+ )
)
},
),