From 1a3c647adf1f252478bf38537bde87f7e5f14ab0 Mon Sep 17 00:00:00 2001 From: Jan Hrastnik Date: Fri, 13 Nov 2020 00:07:21 +0100 Subject: added col_height calculation --- helix-view/src/prompt.rs | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) (limited to 'helix-view/src') diff --git a/helix-view/src/prompt.rs b/helix-view/src/prompt.rs index 8186b476..e2a9c80d 100644 --- a/helix-view/src/prompt.rs +++ b/helix-view/src/prompt.rs @@ -68,25 +68,14 @@ impl Prompt { } pub fn change_completion_selection(&mut self) { - if !self.completion.is_empty() { - self.completion_selection_index = self - .completion_selection_index - .map(|i| { - if i == self.completion.len() - 1 { - 0 - } else { - i + 1 - } - }) - .or(Some(0)); - self.line = String::from( - self.completion - .get(self.completion_selection_index.unwrap()) - .unwrap(), - ); + if self.completion.is_empty() { + return; } + let index = + self.completion_selection_index.map(|i| i + 1).unwrap_or(0) % self.completion.len(); + self.completion_selection_index = Some(index); + self.line = self.completion[index].clone(); } - pub fn exit_selection(&mut self) { self.completion_selection_index = None; } -- cgit v1.2.3-70-g09d2