Make function more concise
This commit is contained in:
parent
5b5368ce6f
commit
153e7977d3
@ -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>> {
|
fn complete(&self, word: &str, prompter: &::linefeed::prompter::Prompter<T>, start: usize, _end: usize) -> Option<Vec<Completion>> {
|
||||||
let line = prompter.buffer();
|
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 words = line[1..(if start == 0 { 1 } else { start })].split_whitespace();
|
||||||
let mut completions = Vec::new();
|
let mut completions = Vec::new();
|
||||||
let mut command_tree: Option<&CommandTree> = Some(&self.top_level_commands);
|
let mut command_tree: Option<&CommandTree> = Some(&self.top_level_commands);
|
||||||
@ -343,8 +346,5 @@ impl<T: Terminal> Completer<T> for TabCompleteHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(completions)
|
Some(completions)
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user