Make function more concise

This commit is contained in:
greg 2019-03-20 00:24:46 -07:00
parent 5b5368ce6f
commit 153e7977d3
1 changed files with 32 additions and 32 deletions

View File

@ -308,7 +308,10 @@ impl<T: Terminal> Completer<T> for TabCompleteHandler {
fn complete(&self, word: &str, prompter: &::linefeed::prompter::Prompter<T>, start: usize, _end: usize) -> Option<Vec<Completion>> {
let line = prompter.buffer();
if line.starts_with(&format!("{}", self.sigil)) {
if !line.starts_with(self.sigil) {
return None;
}
let mut words = line[1..(if start == 0 { 1 } else { start })].split_whitespace();
let mut completions = Vec::new();
let mut command_tree: Option<&CommandTree> = Some(&self.top_level_commands);
@ -343,8 +346,5 @@ impl<T: Terminal> Completer<T> for TabCompleteHandler {
}
}
Some(completions)
} else {
None
}
}
}