summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrabite <rabite@posteo.de>2020-01-26 15:40:13 +0100
committerrabite <rabite@posteo.de>2020-01-26 16:08:21 +0100
commit89aef8ba76a1d360ccb04d5b5a493f80eafa3ef0 (patch)
tree658f1503ccc21bff33112ff8b64c41ca94dc8d1f
parent64391dd98c6446a7f6aeae406e85fe50072994c4 (diff)
fix crash when completing
-rw-r--r--src/minibuffer.rs11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/minibuffer.rs b/src/minibuffer.rs
index d2d4f56..d6d4e47 100644
--- a/src/minibuffer.rs
+++ b/src/minibuffer.rs
@@ -244,7 +244,7 @@ impl MiniBuffer {
let last_len = last_comp.len();
self.input = self.input.trim_end_matches(last_comp).to_string();
- self.position -= last_len;
+ self.position = self.position.saturating_sub(last_len);
let next_comp = self.completions.pop()?;
let next_comp = next_comp.to_string_lossy();
@@ -366,7 +366,7 @@ pub fn find_bins(comp_name: &str) -> HResult<Vec<OsString>> {
let name = file.file_name();
// If length is different that means the file starts with comp_name
- if &name.trim_start(&name).len() != &comp_name.len() {
+ if &name.trim_start(comp_name).len() != &name.len() {
Ok(name)
} else {
Err(HError::NoCompletionsError)
@@ -375,9 +375,10 @@ pub fn find_bins(comp_name: &str) -> HResult<Vec<OsString>> {
})
})
}).flatten()
- .flatten()
- .filter_map(|s| s.ok())
- .collect::<Vec<OsString>>();
+ .flatten()
+ .filter(|s| s.is_ok())
+ .map(|s| s.unwrap())
+ .collect::<Vec<OsString>>();
if completions.is_empty() { return Err(HError::NoCompletionsError); }