Fixed tree_walking for the new breadcrumbs.

This commit is contained in:
Tom Alexander 2020-06-06 22:29:39 -04:00
parent 71592a9a32
commit 256dcd03c5
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE

View File

@ -56,21 +56,15 @@ pub fn walk_path<'a, P>(
where where
P: Borrow<str>, P: Borrow<str>,
{ {
/* match (breadcrumbs.last(), path.first()) {
match (breadcrumbs.is_empty(), path.first()) { (None, _) => return Err(WalkError::CantWalk),
(true, _) => return Err(WalkError::CantWalk), (Some(last_elem), None) => return Ok(last_elem.borrow()),
(false, None) => { (Some(_), Some(path_first)) if path_first.borrow() == "." => {
return breadcrumbs
.last()
.map(|bte| bte.borrow())
.ok_or(WalkError::CantWalk)
}
(false, Some(path_first)) if path_first.borrow() == "." => {
let first_non_pseudo_element = get_first_non_pseudo_element(breadcrumbs); let first_non_pseudo_element = get_first_non_pseudo_element(breadcrumbs);
return match first_non_pseudo_element { return match first_non_pseudo_element {
None => Err(WalkError::CantWalk), None => Err(WalkError::CantWalk),
Some(current_context) => { Some(current_context) => {
match walk_path_from_single_level(current_context.get_ice(), &path[1..]) { match walk_path_from_single_level(current_context.borrow(), &path[1..]) {
// If no walking was done at all or we partially walked // If no walking was done at all or we partially walked
// then stop trying to find anything because '.' restricts // then stop trying to find anything because '.' restricts
// us to the current scope // us to the current scope
@ -80,9 +74,9 @@ where
} }
}; };
} }
(false, Some(path_first)) => { (Some(_), Some(path_first)) => {
for context in breadcrumbs.ice_iter() { for context in breadcrumbs.iter().rev() {
match walk_path_from_single_level(context, path) { match walk_path_from_single_level(context.borrow(), path) {
// If no walking was done at all, keep looping // If no walking was done at all, keep looping
WalkResult::NoWalk => {} WalkResult::NoWalk => {}
// If we partially walked then stop trying to find // If we partially walked then stop trying to find
@ -97,6 +91,4 @@ where
} }
Err(WalkError::CantWalk) Err(WalkError::CantWalk)
*/
todo!()
} }