summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAzad <49314270+Akmadan23@users.noreply.github.com>2023-08-05 00:45:12 +0200
committerGitHub <noreply@github.com>2023-08-04 18:45:12 -0400
commitfc2fdf3ca79cbfba18350dd5faaf548d7a98f96f (patch)
tree641deb96c0b38aab49424818ce3513e13a318eee
parenta97ca3027bf66dbf16db7737ad5288fa9aaa89f2 (diff)
fix #388 (#389)
-rw-r--r--src/commands/change_directory.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/commands/change_directory.rs b/src/commands/change_directory.rs
index 2327466..23ebfc6 100644
--- a/src/commands/change_directory.rs
+++ b/src/commands/change_directory.rs
@@ -12,10 +12,15 @@ pub fn cd(path: &path::Path, context: &mut AppContext) -> std::io::Result<()> {
Ok(())
}
-pub fn change_directory(context: &mut AppContext, path: &path::Path) -> JoshutoResult {
+pub fn change_directory(context: &mut AppContext, mut path: &path::Path) -> JoshutoResult {
let new_cwd = if path.is_absolute() {
path.to_path_buf()
} else {
+ while let Ok(p) = path.strip_prefix("../") {
+ parent_directory(context)?;
+ path = p;
+ }
+
let mut new_cwd = std::env::current_dir()?;
new_cwd.push(path);
new_cwd