summaryrefslogtreecommitdiffstats
path: root/src/commands/new_directory.rs
blob: 8364d9346602f681270a3299dc5f96e5fe432b95 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use std::path;

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

pub fn new_directory(context: &mut AppContext, p: &path::Path) -> JoshutoResult<()> {
    std::fs::create_dir_all(p)?;
    let options = context.config_ref().display_options_ref().clone();
    let curr_path = context.tab_context_ref().curr_tab_ref().cwd().to_path_buf();
    for tab in context.tab_context_mut().iter_mut() {
        tab.history_mut().reload(&curr_path, &options)?;
    }
    Ok(())
}