fix: use correct base directory for path completion (#854)

* fix wrong diff_path

* refactor: simplify no base.parent()
This commit is contained in:
Yifan Song 2024-11-20 04:14:29 +01:00 committed by GitHub
parent 6c342eb23e
commit e2c8418c35
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1562,7 +1562,11 @@ pub fn complete_path(
// diff with root
unix_slash(path.vpath().as_rooted_path())
} else {
let base = base.vpath().as_rooted_path();
let base = base
.vpath()
.as_rooted_path()
.parent()
.unwrap_or(Path::new("/"));
let path = path.vpath().as_rooted_path();
let w = pathdiff::diff_paths(path, base)?;
unix_slash(&w)