Add support in the renderer for handling paths containing dot.
This commit is contained in:
parent
95dc15f103
commit
50079c6415
@ -9,7 +9,7 @@ enum WalkResult<'a> {
|
|||||||
|
|
||||||
fn walk_path_from_single_level<'a>(
|
fn walk_path_from_single_level<'a>(
|
||||||
context: &'a dyn ContextElement,
|
context: &'a dyn ContextElement,
|
||||||
path: &Vec<&str>,
|
path: &[&str],
|
||||||
) -> WalkResult<'a> {
|
) -> WalkResult<'a> {
|
||||||
if path.is_empty() {
|
if path.is_empty() {
|
||||||
return WalkResult::FullyWalked(context);
|
return WalkResult::FullyWalked(context);
|
||||||
@ -18,7 +18,6 @@ fn walk_path_from_single_level<'a>(
|
|||||||
let mut walk_failure = WalkResult::NoWalk;
|
let mut walk_failure = WalkResult::NoWalk;
|
||||||
let mut output = context;
|
let mut output = context;
|
||||||
for elem in path.iter() {
|
for elem in path.iter() {
|
||||||
let new_val = output.walk(elem);
|
|
||||||
match output.walk(elem) {
|
match output.walk(elem) {
|
||||||
Err(WalkError::CantWalk { .. }) => {
|
Err(WalkError::CantWalk { .. }) => {
|
||||||
return walk_failure;
|
return walk_failure;
|
||||||
@ -37,6 +36,25 @@ pub fn walk_path<'a>(
|
|||||||
breadcrumbs: &Vec<&'a dyn ContextElement>,
|
breadcrumbs: &Vec<&'a dyn ContextElement>,
|
||||||
path: &'a Vec<&str>,
|
path: &'a Vec<&str>,
|
||||||
) -> Result<&'a dyn ContextElement, WalkError> {
|
) -> Result<&'a dyn ContextElement, WalkError> {
|
||||||
|
if path.is_empty() {
|
||||||
|
return Ok(*breadcrumbs
|
||||||
|
.last()
|
||||||
|
.expect("Breadcrumbs should never be empty"));
|
||||||
|
}
|
||||||
|
if *path.first().expect("Already proved path is not empty") == "." {
|
||||||
|
return match walk_path_from_single_level(
|
||||||
|
*breadcrumbs
|
||||||
|
.last()
|
||||||
|
.expect("Breadcrumbs should never be empty"),
|
||||||
|
&path[1..],
|
||||||
|
) {
|
||||||
|
// If no walking was done at all or we partially walked
|
||||||
|
// then stop trying to find anything because '.' restricts
|
||||||
|
// us to the current scope
|
||||||
|
WalkResult::NoWalk | WalkResult::PartialWalk => Err(WalkError::CantWalk),
|
||||||
|
WalkResult::FullyWalked(new_context) => Ok(new_context),
|
||||||
|
};
|
||||||
|
}
|
||||||
for context in breadcrumbs.iter().rev() {
|
for context in breadcrumbs.iter().rev() {
|
||||||
match walk_path_from_single_level(*context, path) {
|
match walk_path_from_single_level(*context, path) {
|
||||||
// If no walking was done at all, keep looping
|
// If no walking was done at all, keep looping
|
||||||
|
Loading…
x
Reference in New Issue
Block a user