From 3494bb8ef0e3c43e0507d264867c1e1e572c2367 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kevin=20Sj=C3=B6berg?= Date: Sun, 6 Jun 2021 09:49:37 +0200 Subject: [PATCH] Refactor index assignment Co-authored-by: Ivan Tham --- helix-term/src/ui/prompt.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/helix-term/src/ui/prompt.rs b/helix-term/src/ui/prompt.rs index 95c42fbc4..5b074d019 100644 --- a/helix-term/src/ui/prompt.rs +++ b/helix-term/src/ui/prompt.rs @@ -91,13 +91,11 @@ impl Prompt { } let index = match direction { - CompletionDirection::Forward => { - self.selection.map_or(0, |i| i + 1) % self.completion.len() - } + CompletionDirection::Forward => self.selection.map_or(0, |i| i + 1), CompletionDirection::Backward => { - (self.selection.unwrap_or(0) + self.completion.len() - 1) % self.completion.len() + self.selection.unwrap_or(0) + self.completion.len() - 1 } - }; + } % self.completion.len(); self.selection = Some(index);