diff options
author | Jiayi Zhao <jeff.no.zhao@gmail.com> | 2019-08-03 10:32:50 -0400 |
---|---|---|
committer | Jiayi Zhao <jeff.no.zhao@gmail.com> | 2019-08-03 10:38:22 -0400 |
commit | 8105aa532c7fca7160ba3ce9303ba7613c59d277 (patch) | |
tree | 1cd680e77463bdce2b4b8381a0dcd1ec5b35e17e /src/preview.rs | |
parent | 0b8747eb37d6d943d90e15ed82858d99d1800425 (diff) |
Make xdg_open toggleable
- xdg_open option automatically opens file
rather than asking user what to do
- fix crash when trying to open something in an
empty directory
Diffstat (limited to 'src/preview.rs')
-rw-r--r-- | src/preview.rs | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/src/preview.rs b/src/preview.rs index 282ae43..0f97a22 100644 --- a/src/preview.rs +++ b/src/preview.rs @@ -47,15 +47,21 @@ fn preview_directory( path: &path::Path, win: &JoshutoPanel, config_t: &JoshutoConfig, -) { +) -> std::io::Result<()> { match history.entry(path.to_path_buf().clone()) { Entry::Occupied(mut entry) => { - ui::display_contents( - win, - entry.get_mut(), - config_t, - &ui::SECONDARY_DISPLAY_OPTION, - ); + let mut dirlist = entry.get_mut(); + if dirlist.need_update() { + dirlist.reload_contents(&config_t.sort_option)? + } else { + let metadata = std::fs::symlink_metadata(dirlist.file_path())?; + + let modified = metadata.modified()?; + if modified > dirlist.metadata.modified { + dirlist.reload_contents(&config_t.sort_option)? + } + } + ui::display_contents(win, dirlist, config_t, &ui::SECONDARY_DISPLAY_OPTION); } Entry::Vacant(entry) => { if let Ok(s) = JoshutoDirList::new(path.to_path_buf().clone(), &config_t.sort_option) { @@ -69,6 +75,7 @@ fn preview_directory( } } win.queue_for_refresh(); + Ok(()) } fn preview_file(entry: &JoshutoDirEntry, win: &JoshutoPanel) { |