diff --git a/crates/ui/src/components/keybinding.rs b/crates/ui/src/components/keybinding.rs index d595c6c4d0..5212705edc 100644 --- a/crates/ui/src/components/keybinding.rs +++ b/crates/ui/src/components/keybinding.rs @@ -66,6 +66,17 @@ impl KeyBinding { impl RenderOnce for KeyBinding { fn render(self, cx: &mut WindowContext) -> impl IntoElement { h_flex() + .debug_selector(|| { + format!( + "KEY_BINDING-{}", + self.key_binding + .keystrokes() + .iter() + .map(|k| k.key.to_string()) + .collect::>() + .join(" ") + ) + }) .flex_none() .gap_2() .children(self.key_binding.keystrokes().iter().map(|keystroke| { diff --git a/crates/vim/src/test.rs b/crates/vim/src/test.rs index 9eff14f4fb..f8b32fee5a 100644 --- a/crates/vim/src/test.rs +++ b/crates/vim/src/test.rs @@ -1038,3 +1038,12 @@ async fn test_undo(cx: &mut gpui::TestAppContext) { 3"}) .await; } + +#[gpui::test] +async fn test_command_palette(cx: &mut gpui::TestAppContext) { + let mut cx = VimTestContext::new(cx, true).await; + cx.simulate_keystroke(":"); + cx.simulate_input("go to definition"); + assert!(cx.debug_bounds("KEY_BINDING-f12").is_none()); + assert!(cx.debug_bounds("KEY_BINDING-g d").is_some()); +} diff --git a/crates/vim/src/vim.rs b/crates/vim/src/vim.rs index 79a8b554a8..f8782b9444 100644 --- a/crates/vim/src/vim.rs +++ b/crates/vim/src/vim.rs @@ -23,8 +23,8 @@ use editor::{ Editor, EditorEvent, EditorMode, }; use gpui::{ - actions, impl_actions, Action, AppContext, EntityId, Global, KeystrokeEvent, Subscription, - View, ViewContext, WeakView, WindowContext, + actions, impl_actions, Action, AppContext, EntityId, FocusableView, Global, KeystrokeEvent, + Subscription, View, ViewContext, WeakView, WindowContext, }; use language::{CursorShape, Point, Selection, SelectionGoal, TransactionId}; pub use mode_indicator::ModeIndicator; @@ -700,8 +700,10 @@ impl Vim { editor.selections.line_mode = matches!(state.mode, Mode::VisualLine); if editor.is_focused(cx) { editor.set_keymap_context_layer::(state.keymap_context_layer(), cx); - } else { - editor.remove_keymap_context_layer::(cx); + // disables vim if the rename editor is focused, + // but not if the command palette is open. + } else if editor.focus_handle(cx).contains_focused(cx) { + editor.remove_keymap_context_layer::(cx) } }); }