diff options
author | Jiayi Zhao <jeff.no.zhao@gmail.com> | 2019-02-24 14:44:48 -0500 |
---|---|---|
committer | Jiayi Zhao <jeff.no.zhao@gmail.com> | 2019-02-24 14:44:48 -0500 |
commit | 8ed156ad708628cee49616a5163ea62f80b27dcb (patch) | |
tree | e62c1a1cce3125694c19339ffc5cc6b97404bbf1 /src/commands/change_directory.rs | |
parent | 99af9db3b22f139b31a56b6a1f54612aacb73b6f (diff) |
fix problem if cd fails
Diffstat (limited to 'src/commands/change_directory.rs')
-rw-r--r-- | src/commands/change_directory.rs | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/commands/change_directory.rs b/src/commands/change_directory.rs index bf29fe8..de0f418 100644 --- a/src/commands/change_directory.rs +++ b/src/commands/change_directory.rs @@ -22,16 +22,10 @@ impl ChangeDirectory { pub fn change_directory(path: &path::PathBuf, context: &mut JoshutoContext) { if !path.exists() { ui::wprint_err(&context.views.bot_win, "Error: No such file or directory"); - ncurses::doupdate(); return; } let curr_tab = &mut context.tabs[context.curr_tab_index]; - let parent_list = curr_tab.parent_list.take(); - curr_tab.history.put_back(parent_list); - let curr_list = curr_tab.curr_list.take(); - curr_tab.history.put_back(curr_list); - match std::env::set_current_dir(path.as_path()) { Ok(_) => { curr_tab.curr_path = path.clone(); @@ -41,6 +35,12 @@ impl ChangeDirectory { return; } } + + let parent_list = curr_tab.parent_list.take(); + curr_tab.history.put_back(parent_list); + let curr_list = curr_tab.curr_list.take(); + curr_tab.history.put_back(curr_list); + curr_tab .history .populate_to_root(&curr_tab.curr_path, &context.config_t.sort_type); @@ -51,8 +51,8 @@ impl ChangeDirectory { { Ok(s) => Some(s), Err(e) => { - eprintln!("{}", e); - process::exit(1); + ui::wprint_err(&context.views.bot_win, e.to_string().as_str()); + None } }; @@ -63,8 +63,8 @@ impl ChangeDirectory { { Ok(s) => Some(s), Err(e) => { - eprintln!("{}", e); - process::exit(1); + ui::wprint_err(&context.views.bot_win, e.to_string().as_str()); + None } }; } |