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.

editor: Fix cursor doesn’t move up and down on arrow keys when no completions are shown (#34678)

Smit Barmasea7284adafab2
diff --git a/crates/editor/src/code_context_menus.rs b/crates/editor/src/code_context_menus.rs
index c7477837dd0..9f842836ed2 100644
--- a/crates/editor/src/code_context_menus.rs
+++ b/crates/editor/src/code_context_menus.rs
@@ -1384,7 +1384,7 @@ impl CodeActionsMenu {
}
}
- fn visible(&self) -> bool {
+ pub fn visible(&self) -> bool {
!self.actions.is_empty()
}
diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs
index 6ad4fc0318a..c3187f6b511 100644
--- a/crates/editor/src/editor.rs
+++ b/crates/editor/src/editor.rs
@@ -2382,13 +2382,17 @@ impl Editor {
}
match self.context_menu.borrow().as_ref() {
- Some(CodeContextMenu::Completions(_)) => {
- key_context.add("menu");
- key_context.add("showing_completions");
+ Some(CodeContextMenu::Completions(menu)) => {
+ if menu.visible() {
+ key_context.add("menu");
+ key_context.add("showing_completions");
+ }
}
- Some(CodeContextMenu::CodeActions(_)) => {
- key_context.add("menu");
- key_context.add("showing_code_actions")
+ Some(CodeContextMenu::CodeActions(menu)) => {
+ if menu.visible() {
+ key_context.add("menu");
+ key_context.add("showing_code_actions")
+ }
}
None => {}
}