Refactor index assignment
Co-authored-by: Ivan Tham <pickfire@riseup.net>
This commit is contained in:
parent
a4ff8cdd8a
commit
3494bb8ef0
1 changed files with 3 additions and 5 deletions
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue