forked from extern/nushell
Attempt at fixing get
command panic.
If possible matches are not found then check if the passed in `obj` parameter is a `string` or a `path`, if so then return it. I am not sure this is the right fix, but I figured I would make an attempt and get a conversation started about it.
This commit is contained in:
parent
04854d5d99
commit
f3eb4fb24e
@ -58,17 +58,32 @@ fn get_member(path: &Tagged<String>, obj: &Tagged<Value>) -> Result<Tagged<Value
|
|||||||
|
|
||||||
possible_matches.sort();
|
possible_matches.sort();
|
||||||
|
|
||||||
|
if possible_matches.len() > 0 {
|
||||||
return Err(ShellError::labeled_error(
|
return Err(ShellError::labeled_error(
|
||||||
"Unknown column",
|
"Unknown column",
|
||||||
format!("did you mean '{}'?", possible_matches[0].1),
|
format!("did you mean '{}'?", possible_matches[0].1),
|
||||||
path.tag(),
|
path.tag(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
match obj {
|
||||||
|
Tagged {
|
||||||
|
item: Value::Primitive(Primitive::String(_)),
|
||||||
|
..
|
||||||
|
} => current = Some(obj),
|
||||||
|
Tagged {
|
||||||
|
item: Value::Primitive(Primitive::Path(_)),
|
||||||
|
..
|
||||||
|
} => current = Some(obj),
|
||||||
|
_ => {}
|
||||||
|
};
|
||||||
|
|
||||||
match current {
|
match current {
|
||||||
Some(v) => Ok(v.clone()),
|
Some(v) => Ok(v.clone()),
|
||||||
|
Loading…
Reference in New Issue
Block a user