diff options
author | Jan Hrastnik | 2020-11-12 23:07:21 +0000 |
---|---|---|
committer | Jan Hrastnik | 2020-11-12 23:07:21 +0000 |
commit | 1a3c647adf1f252478bf38537bde87f7e5f14ab0 (patch) | |
tree | b419e4ac033207d20ec6ca176b20da072944f996 /helix-view/src | |
parent | 2b44031929c490298cfc29cdd055ca4f22bf4645 (diff) |
added col_height calculation
Diffstat (limited to 'helix-view/src')
-rw-r--r-- | helix-view/src/prompt.rs | 23 |
1 files changed, 6 insertions, 17 deletions
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; } |