From 072513f59f54290d03424d8873a6e6dd46764b7e Mon Sep 17 00:00:00 2001 From: CharlesChen0823 Date: Wed, 4 Sep 2024 17:27:07 +0800 Subject: [PATCH] outline_panel: Fix `j` and `k` not working in outline panel filter (#17293) Closes #17248 Release Notes: - Fixed outline panel filter not working for certain Vim bindings ([#17248](https://github.com/zed-industries/zed/issues/17248)) --- assets/keymaps/default-linux.json | 2 +- assets/keymaps/default-macos.json | 2 +- assets/keymaps/vim.json | 2 +- crates/outline_panel/src/outline_panel.rs | 8 +++++++- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/assets/keymaps/default-linux.json b/assets/keymaps/default-linux.json index 107d6e84f0..6f044c0f71 100644 --- a/assets/keymaps/default-linux.json +++ b/assets/keymaps/default-linux.json @@ -521,7 +521,7 @@ } }, { - "context": "OutlinePanel", + "context": "OutlinePanel && not_editing", "bindings": { "escape": "menu::Cancel", "left": "outline_panel::CollapseSelectedEntry", diff --git a/assets/keymaps/default-macos.json b/assets/keymaps/default-macos.json index 752a05cbee..5ebd3d0ccd 100644 --- a/assets/keymaps/default-macos.json +++ b/assets/keymaps/default-macos.json @@ -528,7 +528,7 @@ } }, { - "context": "OutlinePanel", + "context": "OutlinePanel && not_editing", "bindings": { "escape": "menu::Cancel", "left": "outline_panel::CollapseSelectedEntry", diff --git a/assets/keymaps/vim.json b/assets/keymaps/vim.json index 9e6dfdb720..37a3ee0780 100644 --- a/assets/keymaps/vim.json +++ b/assets/keymaps/vim.json @@ -489,7 +489,7 @@ } }, { - "context": "OutlinePanel", + "context": "OutlinePanel && not_editing", "bindings": { "j": "menu::SelectNext", "k": "menu::SelectPrev", diff --git a/crates/outline_panel/src/outline_panel.rs b/crates/outline_panel/src/outline_panel.rs index 18629f57bf..6605426d59 100644 --- a/crates/outline_panel/src/outline_panel.rs +++ b/crates/outline_panel/src/outline_panel.rs @@ -722,10 +722,16 @@ impl OutlinePanel { ); } - fn dispatch_context(&self, _: &ViewContext) -> KeyContext { + fn dispatch_context(&self, cx: &ViewContext) -> KeyContext { let mut dispatch_context = KeyContext::new_with_defaults(); dispatch_context.add("OutlinePanel"); dispatch_context.add("menu"); + let identifier = if self.filter_editor.focus_handle(cx).is_focused(cx) { + "editing" + } else { + "not_editing" + }; + dispatch_context.add(identifier); dispatch_context }