summaryrefslogtreecommitdiffstats
path: root/src/app/tab.rs
diff options
context:
space:
mode:
authorqkzk <qu3nt1n@gmail.com>2023-12-29 21:50:23 +0100
committerqkzk <qu3nt1n@gmail.com>2023-12-29 21:50:23 +0100
commit27e9bfd11847263a1468fb45307df650f74ebfa9 (patch)
treea071f80b848743b7dc3dbf7738f47435cb50d031 /src/app/tab.rs
parent0302a9f5fafe6981d31015000f1a98f1a7b69d9e (diff)
check before entering a directory
Diffstat (limited to 'src/app/tab.rs')
-rw-r--r--src/app/tab.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/app/tab.rs b/src/app/tab.rs
index e8c1d12..6bccf28 100644
--- a/src/app/tab.rs
+++ b/src/app/tab.rs
@@ -435,6 +435,13 @@ impl Tab {
/// Reset the window.
/// Add the last path to the history of visited paths.
pub fn cd(&mut self, path: &path::Path) -> Result<()> {
+ match std::env::set_current_dir(path) {
+ Ok(()) => (),
+ Err(error) => {
+ crate::log_info!("can't reach {path}. Error {error}", path = path.display());
+ return Ok(());
+ }
+ }
self.history.push(
&self.directory.path,
&self.directory.selected().context("")?.path,
@@ -446,7 +453,6 @@ impl Tab {
}
self.window.reset(self.directory.content.len());
crate::log_info!("done cd: {path}", path = path.display());
- let _ = std::env::set_current_dir(path);
Ok(())
}