diff options
author | Jiayi Zhao <jeff.no.zhao@gmail.com> | 2019-04-25 09:34:14 -0400 |
---|---|---|
committer | Jiayi Zhao <jeff.no.zhao@gmail.com> | 2019-04-25 09:34:14 -0400 |
commit | 8d2db42a122736cee7482b79d2afbdadc146f51b (patch) | |
tree | be31f161fa438ce15146de860dda894ed6820a3e /src/tab.rs | |
parent | 53f530a1ec26fce4664634f9c22fbb51b12c3f42 (diff) |
fix previews not updating when reload_dir is called
Diffstat (limited to 'src/tab.rs')
-rw-r--r-- | src/tab.rs | 35 |
1 files changed, 34 insertions, 1 deletions
@@ -1,4 +1,4 @@ -use std::collections::HashMap; +use std::collections::{hash_map::Entry, HashMap}; use std::path::PathBuf; use crate::config; @@ -39,6 +39,39 @@ impl JoshutoTab { if self.curr_list.path.exists() { self.curr_list.update_contents(sort_option)?; } + match self.curr_list.get_curr_ref() { + Some(s) => { + if s.path.is_dir() { + match self.history.entry(s.path.clone().to_path_buf()) { + Entry::Occupied(mut entry) => { + let dirlist = entry.get_mut(); + if dirlist.need_update() { + dirlist.update_contents(sort_option)?; + } + } + Entry::Vacant(entry) => { + let s = JoshutoDirList::new(s.path.clone().to_path_buf(), sort_option)?; + entry.insert(s); + } + } + } + } + None => {} + }; + if let Some(parent) = self.curr_list.path.parent() { + match self.history.entry(parent.clone().to_path_buf()) { + Entry::Occupied(mut entry) => { + let dirlist = entry.get_mut(); + if dirlist.need_update() { + dirlist.update_contents(sort_option)?; + } + } + Entry::Vacant(entry) => { + let s = JoshutoDirList::new(parent.clone().to_path_buf(), sort_option)?; + entry.insert(s); + } + } + } Ok(()) } |