From 2ac496f919aeef4733367caac06ed4c39975822b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kevin=20Sj=C3=B6berg?= Date: Sun, 6 Jun 2021 10:06:47 +0200 Subject: [PATCH] Do not move past number of matches --- helix-term/src/ui/picker.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/helix-term/src/ui/picker.rs b/helix-term/src/ui/picker.rs index 4cff49179..c35920622 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; } }