From 2ac496f919aeef4733367caac06ed4c39975822b Mon Sep 17 00:00:00 2001 From: Kevin Sjöberg Date: Sun, 6 Jun 2021 10:06:47 +0200 Subject: Do not move past number of matches --- helix-term/src/ui/picker.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'helix-term/src/ui/picker.rs') diff --git a/helix-term/src/ui/picker.rs b/helix-term/src/ui/picker.rs index 4cff4917..c3592062 100644 --- a/helix-term/src/ui/picker.rs +++ b/helix-term/src/ui/picker.rs @@ -100,8 +100,11 @@ impl Picker { } pub fn move_down(&mut self) { - // TODO: len - 1 - if self.cursor < self.options.len() { + if self.matches.is_empty() { + return; + } + + if self.cursor < self.matches.len() - 1 { self.cursor += 1; } } -- cgit v1.2.3-70-g09d2