diff options
author | DLFW <daniel@llin.info> | 2022-08-14 02:04:38 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-13 20:04:38 -0400 |
commit | 6356efaa55830c4ef8ed976a6e89f738ab6e026d (patch) | |
tree | 9f6dde209a7c1e085764538edc2d1679bb50ca80 /src/fs | |
parent | d2ef6d44cc09ad3e57642d5839d972d426bfff12 (diff) |
Sort options individual per tab (#191)
Sort options (sort criterion, reversion, dir-first, and case-sensitivity)
are specific for each tab. Changing sort-options will not have any
affect on tabs other than the currently active one. Each new tab will
start with the default sort-options.
Diffstat (limited to 'src/fs')
-rw-r--r-- | src/fs/dirlist.rs | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/fs/dirlist.rs b/src/fs/dirlist.rs index 33ee7c9..096c9a0 100644 --- a/src/fs/dirlist.rs +++ b/src/fs/dirlist.rs @@ -1,7 +1,7 @@ use std::slice::{Iter, IterMut}; use std::{io, path}; -use crate::config::option::DisplayOption; +use crate::config::option::{DisplayOption, TabDisplayOption}; use crate::context::UiContext; use crate::fs::{JoshutoDirEntry, JoshutoMetadata}; use crate::history::read_directory; @@ -36,12 +36,14 @@ impl JoshutoDirList { } } - pub fn from_path(path: path::PathBuf, options: &DisplayOption) -> io::Result<Self> { + pub fn from_path( + path: path::PathBuf, + options: &DisplayOption, + tab_options: &TabDisplayOption, + ) -> io::Result<Self> { let filter_func = options.filter_func(); - let sort_options = options.sort_options_ref(); - let mut contents = read_directory(path.as_path(), filter_func, options)?; - contents.sort_by(|f1, f2| sort_options.compare(f1, f2)); + contents.sort_by(|f1, f2| tab_options.sort_options_ref().compare(f1, f2)); let index = if contents.is_empty() { None } else { Some(0) }; let metadata = JoshutoMetadata::from(&path)?; |