diff options
author | otakubeam <59658457+otakubeam@users.noreply.github.com> | 2022-01-28 15:41:19 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-28 07:41:19 -0500 |
commit | 65f937083bf6e26b178550d7936dd288ba024e53 (patch) | |
tree | bd47b1f5f29fff9d5f7782df6ca7151003db581d /src | |
parent | dec0e132435155984595aefcea25a420fe52b32d (diff) |
Remove boilerplate (#136)
Co-authored-by: Andrew Orazov <orazov.ae@phystech.edu>
Diffstat (limited to 'src')
-rw-r--r-- | src/context/app_context.rs | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/src/context/app_context.rs b/src/context/app_context.rs index 8c5f907..37c0565 100644 --- a/src/context/app_context.rs +++ b/src/context/app_context.rs @@ -194,15 +194,21 @@ impl AppContext { pub fn update_watcher(&mut self) { // collect the paths that shall be watched... let mut new_paths_to_watch: HashSet<path::PathBuf> = HashSet::with_capacity(3); - if let Some(dir_list) = self.tab_context_ref().curr_tab_ref().curr_list_ref() { - new_paths_to_watch.insert(dir_list.file_path().to_path_buf()); - } - if let Some(dir_list) = self.tab_context_ref().curr_tab_ref().parent_list_ref() { - new_paths_to_watch.insert(dir_list.file_path().to_path_buf()); - } - if let Some(dir_list) = self.tab_context_ref().curr_tab_ref().child_list_ref() { - new_paths_to_watch.insert(dir_list.file_path().to_path_buf()); + + let curr_tab_ref = self.tab_context_ref().curr_tab_ref(); + + let watched_lists = [ + curr_tab_ref.parent_list_ref(), + curr_tab_ref.curr_list_ref(), + curr_tab_ref.child_list_ref(), + ]; + + for list in watched_lists { + if let Some(dir_list) = list { + new_paths_to_watch.insert(dir_list.file_path().to_path_buf()); + } } + // remove paths from watcher which don't need to be watched anymore... for old_watched_path in &self.watched_paths { if !new_paths_to_watch.contains(old_watched_path.as_path()) { |