summaryrefslogtreecommitdiffstats
path: root/src/tab.rs
diff options
context:
space:
mode:
authorJiayi Zhao <jeff.no.zhao@gmail.com>2019-04-02 21:12:22 -0400
committerJiayi Zhao <jeff.no.zhao@gmail.com>2019-04-02 21:12:22 -0400
commit37fa8efbd8691d89fcd22727e3720621fff3680c (patch)
tree8723b96b26f0d30ffa66f8408d5ca2cd93e4a858 /src/tab.rs
parent554f06d72aeb639548314336b2318e14f8ffcc7e (diff)
refactor sorting structs
- filtering hidden files is de-coupled from creating direntries
Diffstat (limited to 'src/tab.rs')
-rw-r--r--src/tab.rs19
1 files changed, 8 insertions, 11 deletions
diff --git a/src/tab.rs b/src/tab.rs
index 1883cb5..e12baad 100644
--- a/src/tab.rs
+++ b/src/tab.rs
@@ -17,34 +17,31 @@ pub struct JoshutoTab {
}
impl JoshutoTab {
- pub fn new(curr_path: PathBuf, sort_type: &sort::SortType) -> Result<Self, std::io::Error> {
+ pub fn new(curr_path: PathBuf, sort_option: &sort::SortOption) -> Result<Self, std::io::Error> {
let mut history = history::DirHistory::new();
- history.populate_to_root(&curr_path, sort_type);
+ history.populate_to_root(&curr_path, sort_option);
- let curr_list: JoshutoDirList = history.pop_or_create(&curr_path, sort_type)?;
+ let curr_list: Option<JoshutoDirList> = Some(history.pop_or_create(&curr_path, sort_option)?);
let parent_list: Option<JoshutoDirList> = match curr_path.parent() {
- Some(parent) => {
- let tmp_list = history.pop_or_create(&parent, sort_type)?;
- Some(tmp_list)
- }
+ Some(parent) => Some(history.pop_or_create(&parent, sort_option)?),
None => None,
};
let tab = JoshutoTab {
curr_path,
history,
- curr_list: Some(curr_list),
+ curr_list,
parent_list,
};
Ok(tab)
}
- pub fn reload_contents(&mut self, sort_type: &sort::SortType) {
+ pub fn reload_contents(&mut self, sort_option: &sort::SortOption) {
let mut list = self.curr_list.take();
if let Some(ref mut s) = list {
if s.path.exists() {
- s.update_contents(sort_type).unwrap();
+ s.update_contents(sort_option).unwrap();
}
};
self.curr_list = list;
@@ -52,7 +49,7 @@ impl JoshutoTab {
list = self.parent_list.take();
if let Some(ref mut s) = list {
if s.path.exists() {
- s.update_contents(sort_type).unwrap();
+ s.update_contents(sort_option).unwrap();
}
};
self.parent_list = list;