diff options
author | Jiayi Zhao <jeff.no.zhao@gmail.com> | 2020-03-18 22:55:09 -0400 |
---|---|---|
committer | Jiayi Zhao <jeff.no.zhao@gmail.com> | 2020-03-18 22:55:09 -0400 |
commit | 06b2d7730d10240b471e859c7988ed219aa4c590 (patch) | |
tree | f5dcca189bb2d79c4def09540eec73cdb832c6b8 /src/history.rs | |
parent | f3081669e488c54ab4fcae2829ea2f58f082c6e7 (diff) |
remove cursormovestub and add rudimentary sort command
Diffstat (limited to 'src/history.rs')
-rw-r--r-- | src/history.rs | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/src/history.rs b/src/history.rs index 16fc8a3..6068b13 100644 --- a/src/history.rs +++ b/src/history.rs @@ -10,7 +10,12 @@ pub trait DirectoryHistory { path: &Path, sort_option: &sort::SortOption, ) -> std::io::Result<()>; - fn create_or_update( + fn create_or_soft_update( + &mut self, + path: &Path, + sort_option: &sort::SortOption, + ) -> std::io::Result<()>; + fn create_or_reload( &mut self, path: &Path, sort_option: &sort::SortOption, @@ -56,7 +61,27 @@ impl DirectoryHistory for JoshutoHistory { Ok(()) } - fn create_or_update( + fn create_or_soft_update( + &mut self, + path: &Path, + sort_option: &sort::SortOption, + ) -> std::io::Result<()> { + match self.entry(path.to_path_buf()) { + Entry::Occupied(mut entry) => { + let dirlist = entry.get_mut(); + if dirlist.need_update() { + dirlist.reload_contents(sort_option)?; + } + } + Entry::Vacant(entry) => { + let dirlist = JoshutoDirList::new(path.to_path_buf(), sort_option)?; + entry.insert(dirlist); + } + } + Ok(()) + } + + fn create_or_reload( &mut self, path: &Path, sort_option: &sort::SortOption, |