Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

outline_panel: Fix `j` and `k` not working in outline panel filter (#17293)

CharlesChen0823072513f59f54
diff --git a/assets/keymaps/default-linux.json b/assets/keymaps/default-linux.json
index 107d6e84f05..6f044c0f710 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 752a05cbee8..5ebd3d0ccd1 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 9e6dfdb7208..37a3ee0780d 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 18629f57bf6..6605426d597 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<Self>) -> KeyContext {
+ fn dispatch_context(&self, cx: &ViewContext<Self>) -> 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
}