mirror of
https://github.com/Llewellynvdm/zoxide.git
synced 2025-04-08 17:21:51 +00:00
Fix lints
This commit is contained in:
parent
439e5d11d6
commit
11535a3fb6
@ -21,7 +21,7 @@ impl Run for Add {
|
||||
let mut db = DatabaseFile::new(data_dir);
|
||||
let mut db = db.open()?;
|
||||
|
||||
for path in self.paths.iter() {
|
||||
for path in &self.paths {
|
||||
let path = if config::resolve_symlinks() {
|
||||
util::canonicalize(path)
|
||||
} else {
|
||||
|
@ -42,7 +42,7 @@ impl Query {
|
||||
print!("{}", selection);
|
||||
} else {
|
||||
let path = selection.get(5..).context("could not read selection from fzf")?;
|
||||
print!("{}", path)
|
||||
print!("{}", path);
|
||||
}
|
||||
} else if self.list {
|
||||
let stdout = io::stdout();
|
||||
|
@ -35,7 +35,7 @@ impl Run for Remove {
|
||||
}
|
||||
}
|
||||
None => {
|
||||
for path in self.paths.iter() {
|
||||
for path in &self.paths {
|
||||
if !db.remove(path) {
|
||||
let path_abs = util::resolve_path(path)?;
|
||||
let path_abs = util::path_to_str(&path_abs)?;
|
||||
|
@ -31,15 +31,8 @@ pub fn echo() -> bool {
|
||||
}
|
||||
|
||||
pub fn exclude_dirs() -> Result<Vec<Pattern>> {
|
||||
match env::var_os("_ZO_EXCLUDE_DIRS") {
|
||||
Some(paths) => env::split_paths(&paths)
|
||||
.map(|path| {
|
||||
let pattern = path.to_str().context("invalid unicode in _ZO_EXCLUDE_DIRS")?;
|
||||
Pattern::new(pattern)
|
||||
.with_context(|| format!("invalid glob in _ZO_EXCLUDE_DIRS: {}", pattern))
|
||||
})
|
||||
.collect(),
|
||||
None => {
|
||||
env::var_os("_ZO_EXCLUDE_DIRS").map_or_else(
|
||||
|| {
|
||||
let pattern = (|| {
|
||||
let home = dirs::home_dir()?;
|
||||
let home = home.to_str()?;
|
||||
@ -47,8 +40,17 @@ pub fn exclude_dirs() -> Result<Vec<Pattern>> {
|
||||
Pattern::new(&home).ok()
|
||||
})();
|
||||
Ok(pattern.into_iter().collect())
|
||||
}
|
||||
}
|
||||
},
|
||||
|paths| {
|
||||
env::split_paths(&paths)
|
||||
.map(|path| {
|
||||
let pattern = path.to_str().context("invalid unicode in _ZO_EXCLUDE_DIRS")?;
|
||||
Pattern::new(pattern)
|
||||
.with_context(|| format!("invalid glob in _ZO_EXCLUDE_DIRS: {}", pattern))
|
||||
})
|
||||
.collect()
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
pub fn fzf_opts() -> Option<OsString> {
|
||||
|
@ -51,7 +51,11 @@ impl<'file> Database<'file> {
|
||||
|
||||
match self.dirs.iter_mut().find(|dir| dir.path == path) {
|
||||
None => {
|
||||
self.dirs.push(Dir { path: path.to_string().into(), last_accessed: now, rank: 1.0 })
|
||||
self.dirs.push(Dir {
|
||||
path: path.to_string().into(),
|
||||
last_accessed: now,
|
||||
rank: 1.0,
|
||||
});
|
||||
}
|
||||
Some(dir) => {
|
||||
dir.last_accessed = now;
|
||||
|
32
src/util.rs
32
src/util.rs
@ -82,16 +82,13 @@ pub fn resolve_path<P: AsRef<Path>>(path: &P) -> Result<PathBuf> {
|
||||
Some(Component::Prefix(prefix)) => match prefix.kind() {
|
||||
Prefix::Disk(drive_letter) => {
|
||||
let disk = components.next().unwrap();
|
||||
match components.peek() {
|
||||
Some(Component::RootDir) => {
|
||||
let root = components.next().unwrap();
|
||||
stack.push(disk);
|
||||
stack.push(root);
|
||||
}
|
||||
_ => {
|
||||
base_path = get_drive_relative(drive_letter)?;
|
||||
stack.extend(base_path.components());
|
||||
}
|
||||
if components.peek() == Some(&Component::RootDir) {
|
||||
let root = components.next().unwrap();
|
||||
stack.push(disk);
|
||||
stack.push(root);
|
||||
} else {
|
||||
base_path = get_drive_relative(drive_letter)?;
|
||||
stack.extend(base_path.components());
|
||||
}
|
||||
}
|
||||
Prefix::VerbatimDisk(drive_letter) => {
|
||||
@ -120,17 +117,12 @@ pub fn resolve_path<P: AsRef<Path>>(path: &P) -> Result<PathBuf> {
|
||||
stack.extend(base_path.components());
|
||||
}
|
||||
}
|
||||
} else if components.peek() == Some(&Component::RootDir) {
|
||||
let root = components.next().unwrap();
|
||||
stack.push(root);
|
||||
} else {
|
||||
match components.peek() {
|
||||
Some(Component::RootDir) => {
|
||||
let root = components.next().unwrap();
|
||||
stack.push(root);
|
||||
}
|
||||
_ => {
|
||||
base_path = current_dir()?;
|
||||
stack.extend(base_path.components());
|
||||
}
|
||||
}
|
||||
base_path = current_dir()?;
|
||||
stack.extend(base_path.components());
|
||||
}
|
||||
|
||||
for component in components {
|
||||
|
Loading…
x
Reference in New Issue
Block a user