diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs index ef2c459aad..101d2297a9 100644 --- a/crates/editor/src/editor.rs +++ b/crates/editor/src/editor.rs @@ -966,8 +966,11 @@ impl CompletionsMenu { ) { if self.selected_item > 0 { self.selected_item -= 1; + } else { + self.selected_item = self.matches.len() - 1; self.list.scroll_to(ScrollTarget::Show(self.selected_item)); } + self.list.scroll_to(ScrollTarget::Show(self.selected_item)); self.attempt_resolve_selected_completion_documentation(project, cx); cx.notify(); } @@ -979,8 +982,10 @@ impl CompletionsMenu { ) { if self.selected_item + 1 < self.matches.len() { self.selected_item += 1; - self.list.scroll_to(ScrollTarget::Show(self.selected_item)); + } else { + self.selected_item = 0; } + self.list.scroll_to(ScrollTarget::Show(self.selected_item)); self.attempt_resolve_selected_completion_documentation(project, cx); cx.notify(); } @@ -1532,17 +1537,23 @@ impl CodeActionsMenu { fn select_prev(&mut self, cx: &mut ViewContext) { if self.selected_item > 0 { self.selected_item -= 1; + } else { + self.selected_item = self.actions.len() - 1; self.list.scroll_to(ScrollTarget::Show(self.selected_item)); - cx.notify() } + self.list.scroll_to(ScrollTarget::Show(self.selected_item)); + cx.notify(); } fn select_next(&mut self, cx: &mut ViewContext) { if self.selected_item + 1 < self.actions.len() { self.selected_item += 1; self.list.scroll_to(ScrollTarget::Show(self.selected_item)); - cx.notify() + } else { + self.selected_item = 0; + self.list.scroll_to(ScrollTarget::Show(self.selected_item)); } + cx.notify(); } fn select_last(&mut self, cx: &mut ViewContext) {