Clean up LocationUp

Path doesn't need to be canonicalized.
This commit is contained in:
Josh Megnauth 2024-02-07 21:11:57 -05:00 committed by Jeremy Soller
parent 2814834251
commit c636ca8b23

View file

@ -627,15 +627,8 @@ impl Tab {
// Sets location to the path's parent
// Does nothing if path is root or location is Trash
if let Location::Path(ref path) = self.location {
// Canonicalize is needed because parent() can return an empty path for
// relative paths which would fail to open.
// Canonicalizing the path should do the right thing of evaluating the path
// so that the parent successfully moves up the hierarchy.
// If it fails (i.e. the path doesn't exist for some reason) then it returns
// to home.
let mut path = path.canonicalize().unwrap_or_else(|_| home_dir());
if path.pop() {
cd = Some(Location::Path(path));
if let Some(parent) = path.parent() {
cd = Some(Location::Path(parent.to_owned()));
}
}
}