Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
vim: Avoid removing keymap context when blurred (#9960)
Mehmet Efe Akçadde27483a453
diff --git a/crates/ui/src/components/keybinding.rs b/crates/ui/src/components/keybinding.rsindex d595c6c4d02..5212705edcc 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::<Vec<_>>()+ .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.rsindex 9eff14f4fb9..f8b32fee5a3 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.rsindex 79a8b554a88..f8782b9444e 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::<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)}});}