Skip to content

Commit

Permalink
ignore files when compressing path components (#8)
Browse files Browse the repository at this point in the history
* don't insert files into filename prefix trie

prefixes are properly considered unique over the set of directories/symlinks to
directories, not over the set of directories, files, and symlinks. in other
words, given a folder containing the directory "colibc", the directory
"clanker", and the file "clacker", "cl" would be a unique prefix indicating the
directory "clanker"

* bump version to 0.5.2
  • Loading branch information
Gregory-Meyer authored Oct 17, 2019
1 parent 9ebc215 commit f09b694
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "clanker"
version = "0.5.1"
version = "0.5.2"
authors = ["Gregory Meyer <[email protected]>"]
edition = "2018"
description = "Minimalistic command prompt for fish."
Expand Down
9 changes: 8 additions & 1 deletion src/compress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ use std::{
borrow::Borrow,
cmp, env,
ffi::{CStr, OsStr, OsString},
fs::{self, Metadata},
io::{self, ErrorKind},
os::unix::ffi::OsStrExt,
path::{Path, PathBuf},
Expand Down Expand Up @@ -103,7 +104,13 @@ fn compress(path: &Path) -> io::Result<String> {
continue;
}

filenames.push(filename.into_string_lossy());
if fs::metadata(&entry.path())
.as_ref()
.map(Metadata::is_dir)
.unwrap_or(true)
{
filenames.push(filename.into_string_lossy());
}
}

let trie: GraphemeClusterTrie = filenames.iter().map(|s| s.as_str()).collect();
Expand Down

0 comments on commit f09b694

Please sign in to comment.