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

use crate::commands::cursor_move;
use crate::context::AppContext;
use crate::error::AppResult;

use super::tab_ops;

pub fn new_directory(context: &mut AppContext, p: &path::Path) -> AppResult {
    std::fs::create_dir_all(p)?;

    let curr_path = context.tab_context_ref().curr_tab_ref().cwd().to_path_buf();
    tab_ops::reload_all_tabs(context, curr_path.as_path())?;

    if context.config_ref().focus_on_create {
        cursor_move::to_path(context, p)?;
    }

    Ok(())
}