@@ -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::<Vec<_>>()
+ .join(" ")
+ )
+ })
.flex_none()
.gap_2()
.children(self.key_binding.keystrokes().iter().map(|keystroke| {
@@ -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());
+}
@@ -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::<Self>(state.keymap_context_layer(), cx);
- } else {
- editor.remove_keymap_context_layer::<Self>(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::<Self>(cx)
}
});
}