Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Wrap over picker's matches when reaching the end of the list
Kirill Bulatov36ed5a31dfd1
diff --git a/crates/picker/src/picker.rs b/crates/picker/src/picker.rsindex 0af4675c980..78d1c09e03a 100644--- a/crates/picker/src/picker.rs+++ b/crates/picker/src/picker.rs@@ -4,7 +4,7 @@ use gpui::{FocusableView, Length, MouseButton, MouseDownEvent, Render, Task, UniformListScrollHandle,View, ViewContext, WindowContext,};-use std::{cmp, sync::Arc};+use std::sync::Arc;use ui::{prelude::*, v_flex, Color, Divider, Label, ListItem, ListItemSpacing, ListSeparator};use workspace::ModalView;@@ -103,7 +103,7 @@ impl<D: PickerDelegate> Picker<D> {let count = self.delegate.match_count();if count > 0 {let index = self.delegate.selected_index();- let ix = cmp::min(index + 1, count - 1);+ let ix = if index == count - 1 { 0 } else { index + 1 };self.delegate.set_selected_index(ix, cx);self.scroll_handle.scroll_to_item(ix);cx.notify();@@ -114,7 +114,7 @@ impl<D: PickerDelegate> Picker<D> {let count = self.delegate.match_count();if count > 0 {let index = self.delegate.selected_index();- let ix = index.saturating_sub(1);+ let ix = if index == 0 { count - 1 } else { index - 1 };self.delegate.set_selected_index(ix, cx);self.scroll_handle.scroll_to_item(ix);cx.notify();