summaryrefslogtreecommitdiffstats
path: root/src/util/load_child.rs
blob: 63fb1f21942dfa901d3f79159aaed719a456dffc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
use std::path::PathBuf;

use crate::context::AppContext;
use crate::history::DirectoryHistory;

pub struct LoadChild {}

impl LoadChild {
    pub fn load_child(context: &mut AppContext) -> std::io::Result<()> {
        let mut path: Option<PathBuf> = None;
        if let Some(curr_list) = context.tab_context_ref().curr_tab_ref().curr_list_ref() {
            if let Some(index) = curr_list.index {
                let entry = &curr_list.contents[index];
                path = Some(entry.file_path().to_path_buf())
            }
        }

        // get preview
        if let Some(path) = path {
            if path.is_dir() {
                let options = context.config_ref().display_options_ref().clone();
                context
                    .tab_context_mut()
                    .curr_tab_mut()
                    .history_mut()
                    .create_or_soft_update(path.as_path(), &options)?;
            }
        }
        Ok(())
    }
}