Formatting
This commit is contained in:
parent
85444426d8
commit
bff8868354
|
|
@ -42,15 +42,16 @@ impl Cmd for Query {
|
||||||
let fuzzy_finder_cmd = fuzzy_finder.cmd_name();
|
let fuzzy_finder_cmd = fuzzy_finder.cmd_name();
|
||||||
let handle = fuzzy_finder.stdin();
|
let handle = fuzzy_finder.stdin();
|
||||||
for dir in matches {
|
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()?;
|
let selection = fuzzy_finder.wait_select()?;
|
||||||
if self.score {
|
if self.score {
|
||||||
print!("{}", selection);
|
print!("{}", selection);
|
||||||
} else {
|
} else {
|
||||||
let path = selection
|
let path = selection.get(5..).with_context(|| {
|
||||||
.get(5..)
|
format!("could not read selection from {}", fuzzy_finder_cmd)
|
||||||
.with_context(|| format!("could not read selection from {}", fuzzy_finder_cmd))?;
|
})?;
|
||||||
print!("{}", path)
|
print!("{}", path)
|
||||||
}
|
}
|
||||||
} else if self.list {
|
} else if self.list {
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ use std::process::{Child, ChildStdin, Command, Stdio};
|
||||||
|
|
||||||
pub struct FuzzyFinder {
|
pub struct FuzzyFinder {
|
||||||
child: Child,
|
child: Child,
|
||||||
fuzzy_finder: &'static str
|
fuzzy_finder: &'static str,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FuzzyFinder {
|
impl FuzzyFinder {
|
||||||
|
|
@ -26,7 +26,9 @@ impl FuzzyFinder {
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(Self {
|
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,
|
fuzzy_finder,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -48,7 +50,8 @@ impl FuzzyFinder {
|
||||||
|
|
||||||
match output.status.code() {
|
match output.status.code() {
|
||||||
// normal exit
|
// 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
|
// no match
|
||||||
Some(1) => bail!("no match found"),
|
Some(1) => bail!("no match found"),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue