on master help sign in
Refactor index assignment

Co-authored-by: Ivan Tham <pickfire@riseup.net>

commit3494bb8ef0e3c43e0507d264867c1e1e572c2367 authorKevin Sjöberg <mail@kevinsjoberg.com> dateSun 6 Jun 2021, 09:49 (5 years ago) parenta4ff8cd
1 file changed+3−5
helix-term/src/ui/prompt.rs+3−5
helix-term/src/ui/prompt.rs+3−5
@@ -91,13 +91,11 @@ impl Prompt {
9191 }
9292
9393 let index = match direction {
94− CompletionDirection::Forward => {
95− self.selection.map_or(0, |i| i + 1) % self.completion.len()
96− }
94+ CompletionDirection::Forward => self.selection.map_or(0, |i| i + 1),
9795 CompletionDirection::Backward => {
98− (self.selection.unwrap_or(0) + self.completion.len() - 1) % self.completion.len()
96+ self.selection.unwrap_or(0) + self.completion.len() - 1
9997 }
100− };
98+ } % self.completion.len();
10199
102100 self.selection = Some(index);
103101