Use FuzzyFinder instead of Fzf, with the proper command name in errors
This commit is contained in:
parent
ecf57afb1b
commit
26596712e8
|
|
@ -1,6 +1,6 @@
|
||||||
use super::Cmd;
|
use super::Cmd;
|
||||||
use crate::config;
|
use crate::config;
|
||||||
use crate::fzf::Fzf;
|
use crate::fuzzy_finder::FuzzyFinder;
|
||||||
use crate::util;
|
use crate::util;
|
||||||
|
|
||||||
use crate::store::{self, Store};
|
use crate::store::{self, Store};
|
||||||
|
|
@ -38,18 +38,19 @@ impl Cmd for Query {
|
||||||
let mut matches = store.iter_matches(&query, now);
|
let mut matches = store.iter_matches(&query, now);
|
||||||
|
|
||||||
if self.interactive {
|
if self.interactive {
|
||||||
let mut fzf = Fzf::new()?;
|
let mut fuzzy_finder = FuzzyFinder::new()?;
|
||||||
let handle = fzf.stdin();
|
let fuzzy_finder_cmd = fuzzy_finder.cmd_name();
|
||||||
|
let handle = fuzzy_finder.stdin();
|
||||||
for dir in matches {
|
for dir in matches {
|
||||||
writeln!(handle, "{}", dir.display_score(now)).context("could not write to fzf")?;
|
writeln!(handle, "{}", dir.display_score(now)).with_context(|| format!("could not write to {}", fuzzy_finder_cmd))?;
|
||||||
}
|
}
|
||||||
let selection = fzf.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..)
|
.get(5..)
|
||||||
.context("could not read selection from fzf")?;
|
.with_context(|| format!("could not read selection from {}", fuzzy_finder_cmd))?;
|
||||||
print!("{}", path)
|
print!("{}", path)
|
||||||
}
|
}
|
||||||
} else if self.list {
|
} else if self.list {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue