diff options
author | Jan Hrastnik | 2020-11-03 09:57:12 +0000 |
---|---|---|
committer | Jan Hrastnik | 2020-11-03 09:57:12 +0000 |
commit | 2b44031929c490298cfc29cdd055ca4f22bf4645 (patch) | |
tree | 3452f7cb44b78e43cbbfc99ee62cd36759d4c788 /helix-view/src/prompt.rs | |
parent | c9e9fcf7c549fe98f5ac5f13cdee213da9c9ad7a (diff) |
various fixes
Diffstat (limited to 'helix-view/src/prompt.rs')
-rw-r--r-- | helix-view/src/prompt.rs | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/helix-view/src/prompt.rs b/helix-view/src/prompt.rs index 749e54d2..8186b476 100644 --- a/helix-view/src/prompt.rs +++ b/helix-view/src/prompt.rs @@ -6,17 +6,17 @@ pub struct Prompt { pub prompt: String, pub line: String, pub cursor: usize, - pub completion: Option<Vec<String>>, + pub completion: Vec<String>, pub should_close: bool, pub completion_selection_index: Option<usize>, - completion_fn: Box<dyn FnMut(&str) -> Option<Vec<String>>>, + completion_fn: Box<dyn FnMut(&str) -> Vec<String>>, callback_fn: Box<dyn FnMut(&mut Editor, &str)>, } impl Prompt { pub fn new( prompt: String, - mut completion_fn: impl FnMut(&str) -> Option<Vec<String>> + 'static, + mut completion_fn: impl FnMut(&str) -> Vec<String> + 'static, callback_fn: impl FnMut(&mut Editor, &str) + 'static, ) -> Prompt { Prompt { @@ -68,11 +68,11 @@ impl Prompt { } pub fn change_completion_selection(&mut self) { - if self.completion.is_some() { + if !self.completion.is_empty() { self.completion_selection_index = self .completion_selection_index .map(|i| { - if i == self.completion.as_ref().unwrap().len() - 1 { + if i == self.completion.len() - 1 { 0 } else { i + 1 @@ -81,8 +81,6 @@ impl Prompt { .or(Some(0)); self.line = String::from( self.completion - .as_ref() - .unwrap() .get(self.completion_selection_index.unwrap()) .unwrap(), ); |