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.

Scroll completions menu to new selection on filter, fix corner case (#23478)

Michael Sloan09fe1e7f66cc
diff --git a/crates/editor/src/code_context_menus.rs b/crates/editor/src/code_context_menus.rs
index ed84a6cf56e..fbe413d9479 100644
--- a/crates/editor/src/code_context_menus.rs
+++ b/crates/editor/src/code_context_menus.rs
@@ -865,18 +865,22 @@ impl CompletionsMenu {
drop(completions);
let mut entries = self.entries.borrow_mut();
- if let Some(CompletionEntry::InlineCompletionHint(_)) = entries.first() {
+ let new_selection = if let Some(CompletionEntry::InlineCompletionHint(_)) = entries.first()
+ {
entries.truncate(1);
if inline_completion_was_selected || matches.is_empty() {
- self.selected_item = 0;
+ 0
} else {
- self.selected_item = 1;
+ 1
}
} else {
entries.truncate(0);
- self.selected_item = 0;
- }
+ 0
+ };
entries.extend(matches.into_iter().map(CompletionEntry::Match));
+ self.selected_item = new_selection;
+ self.scroll_handle
+ .scroll_to_item(new_selection, ScrollStrategy::Top);
}
}