Added better output in query when already in the matched directory
This commit is contained in:
parent
c3e3c855ca
commit
33120f8333
|
|
@ -1,6 +1,8 @@
|
||||||
use std::io::{self, Write};
|
|
||||||
|
|
||||||
use anyhow::{Context, Result};
|
use anyhow::{Context, Result};
|
||||||
|
use std::env;
|
||||||
|
use std::io::{self, Write};
|
||||||
|
use std::path::PathBuf;
|
||||||
|
use std::str::FromStr;
|
||||||
|
|
||||||
use crate::cmd::{Query, Run};
|
use crate::cmd::{Query, Run};
|
||||||
use crate::config;
|
use crate::config;
|
||||||
|
|
@ -64,7 +66,21 @@ impl Query {
|
||||||
}
|
}
|
||||||
handle.flush().pipe_exit("stdout")?;
|
handle.flush().pipe_exit("stdout")?;
|
||||||
} else {
|
} else {
|
||||||
let dir = stream.next().context("no match found")?;
|
let excluded_dir = self.exclude.as_ref().map_or(PathBuf::new(), |path| PathBuf::from_str(path).unwrap());
|
||||||
|
|
||||||
|
let try_dir = stream.next();
|
||||||
|
let dir = match try_dir {
|
||||||
|
Some(dir) => dir,
|
||||||
|
None => {
|
||||||
|
// Current Directory is passed as excluded in __zoxide_z
|
||||||
|
if excluded_dir == env::current_dir()? {
|
||||||
|
try_dir.context("already in the matched directory")?
|
||||||
|
} else {
|
||||||
|
try_dir.context("no match found")?
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
if self.score {
|
if self.score {
|
||||||
writeln!(io::stdout(), "{}", dir.display_score(now))
|
writeln!(io::stdout(), "{}", dir.display_score(now))
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue