Add test for new sorting behavior

This commit is contained in:
Kay Simmons 2023-02-25 14:06:54 -08:00
parent 0b48e238f2
commit 36f3d3d738
3 changed files with 50 additions and 11 deletions

View file

@ -194,13 +194,9 @@ fn distance_to_relative_ancestor(path: &Path, relative_to: &Option<Arc<Path>>) -
return usize::MAX;
};
for (path_ancestor_count, path_ancestor) in path.ancestors().enumerate() {
for (relative_ancestor_count, relative_ancestor) in relative_to.ancestors().enumerate() {
if path_ancestor == relative_ancestor {
return path_ancestor_count + relative_ancestor_count;
}
}
}
let mut path_components = path.components();
let mut relative_components = relative_to.components();
usize::MAX
while path_components.next() == relative_components.next() {}
path_components.count() + relative_components.count() + 1
}