|
|
@@ -33,6 +33,14 @@ pub enum FileFilterFlags {
|
|
|
|
|
|
/// Whether to explicitly show symlinks
|
|
|
ShowSymlinks,
|
|
|
+
|
|
|
+ /// Whether directories should be listed first, and other types of file
|
|
|
+ /// second. Some users prefer it like this.
|
|
|
+ ListDirsFirst,
|
|
|
+
|
|
|
+ /// Whether directories should be listed as the last items, after other
|
|
|
+ /// types of file. Some users prefer it like this.
|
|
|
+ ListDirsLast,
|
|
|
}
|
|
|
|
|
|
/// The **file filter** processes a list of files before displaying them to
|
|
|
@@ -51,14 +59,6 @@ pub enum FileFilterFlags {
|
|
|
/// performing the comparison.
|
|
|
#[derive(PartialEq, Eq, Debug, Clone)]
|
|
|
pub struct FileFilter {
|
|
|
- /// Whether directories should be listed first, and other types of file
|
|
|
- /// second. Some users prefer it like this.
|
|
|
- pub list_dirs_first: bool,
|
|
|
-
|
|
|
- /// Whether directories should be listed as the last items, after other
|
|
|
- /// types of file. Some users prefer it like this.
|
|
|
- pub list_dirs_last: bool,
|
|
|
-
|
|
|
/// The metadata field to sort by.
|
|
|
pub sort_field: SortField,
|
|
|
|
|
|
@@ -143,7 +143,7 @@ impl FileFilter {
|
|
|
files.reverse();
|
|
|
}
|
|
|
|
|
|
- if self.list_dirs_first {
|
|
|
+ if self.flags.contains(&FileFilterFlags::ListDirsFirst) {
|
|
|
// This relies on the fact that `sort_by` is *stable*: it will keep
|
|
|
// adjacent elements next to each other.
|
|
|
files.sort_by(|a, b| {
|
|
|
@@ -151,7 +151,7 @@ impl FileFilter {
|
|
|
.points_to_directory()
|
|
|
.cmp(&a.as_ref().points_to_directory())
|
|
|
});
|
|
|
- } else if self.list_dirs_last {
|
|
|
+ } else if self.flags.contains(&FileFilterFlags::ListDirsLast) {
|
|
|
files.sort_by(|a, b| {
|
|
|
a.as_ref()
|
|
|
.points_to_directory()
|