Formatting

This commit is contained in:
Alexis Bourget 2020-11-23 14:39:42 +01:00
parent 85444426d8
commit bff8868354
2 changed files with 11 additions and 7 deletions

View File

@ -42,15 +42,16 @@ impl Cmd for Query {
let fuzzy_finder_cmd = fuzzy_finder.cmd_name();
let handle = fuzzy_finder.stdin();
for dir in matches {
writeln!(handle, "{}", dir.display_score(now)).with_context(|| format!("could not write to {}", fuzzy_finder_cmd))?;
writeln!(handle, "{}", dir.display_score(now))
.with_context(|| format!("could not write to {}", fuzzy_finder_cmd))?;
}
let selection = fuzzy_finder.wait_select()?;
if self.score {
print!("{}", selection);
} else {
let path = selection
.get(5..)
.with_context(|| format!("could not read selection from {}", fuzzy_finder_cmd))?;
let path = selection.get(5..).with_context(|| {
format!("could not read selection from {}", fuzzy_finder_cmd)
})?;
print!("{}", path)
}
} else if self.list {

View File

@ -7,7 +7,7 @@ use std::process::{Child, ChildStdin, Command, Stdio};
pub struct FuzzyFinder {
child: Child,
fuzzy_finder: &'static str
fuzzy_finder: &'static str,
}
impl FuzzyFinder {
@ -26,7 +26,9 @@ impl FuzzyFinder {
}
Ok(Self {
child: command.spawn().with_context(|| format!("could not launch {}", fuzzy_finder))?,
child: command
.spawn()
.with_context(|| format!("could not launch {}", fuzzy_finder))?,
fuzzy_finder,
})
}
@ -48,7 +50,8 @@ impl FuzzyFinder {
match output.status.code() {
// normal exit
Some(0) => String::from_utf8(output.stdout).with_context(|| format!("invalid unicode in {} output", fuzzy_finder)),
Some(0) => String::from_utf8(output.stdout)
.with_context(|| format!("invalid unicode in {} output", fuzzy_finder)),
// no match
Some(1) => bail!("no match found"),