summaryrefslogtreecommitdiffstats
path: root/src/output
diff options
context:
space:
mode:
authorBen S <ogham@bsago.me>2016-03-31 23:13:15 +0100
committerBen S <ogham@bsago.me>2016-03-31 23:13:15 +0100
commitf6c5c89f55c694f04f9f0a1269f5c4945450d78b (patch)
tree2fb8aab6de42b30cd444a2f81de490e35fabee24 /src/output
parenteaa799c647bc4b714e8883655e3101490c11cf22 (diff)
Always sort files the same way
This fixes a bug where extra sorting options (dirs first, reverse) were not applied when listing in long mode. In other words, fixes #105. The bug occurred because the sorting function only took Files, but the details view uses File eggs that only contain Files. This commit changes the sorting function to accept anything that AsRefs to File, and impls that on both File and Egg so the same function works for both.
Diffstat (limited to 'src/output')
-rw-r--r--src/output/details.rs12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/output/details.rs b/src/output/details.rs
index ed75abf..c663d91 100644
--- a/src/output/details.rs
+++ b/src/output/details.rs
@@ -229,12 +229,18 @@ impl Details {
let mut pool = Pool::new(num_cpus::get() as u32);
let mut file_eggs = Vec::new();
- struct Egg<'_> {
+ struct Egg<'a> {
cells: Vec<TextCell>,
xattrs: Vec<Attribute>,
errors: Vec<(io::Error, Option<PathBuf>)>,
dir: Option<Dir>,
- file: File<'_>,
+ file: File<'a>,
+ }
+
+ impl<'a> AsRef<File<'a>> for Egg<'a> {
+ fn as_ref(&self) -> &File<'a> {
+ &self.file
+ }
}
pool.scoped(|scoped| {
@@ -285,7 +291,7 @@ impl Details {
}
});
- file_eggs.sort_by(|a, b| self.filter.compare_files(&a.file, &b.file));
+ self.filter.sort_files(&mut file_eggs);
let num_eggs = file_eggs.len();
for (index, egg) in file_eggs.into_iter().enumerate() {