forked from extern/nushell
Refactor env conversion, yeet Value::follow_cell_path_not...
(#10926)
# Description Replaces the only usage of `Value::follow_cell_path_not_from_user_input` with some `Record::get`s. # User-Facing Changes Breaking change for `nu-protocol`, since `Value::follow_cell_path_not_from_user_input` was deleted. Nushell now reports errors for when environment conversions are not closures.
This commit is contained in:
@ -919,23 +919,6 @@ impl Value {
|
||||
self,
|
||||
cell_path: &[PathMember],
|
||||
insensitive: bool,
|
||||
) -> Result<Value, ShellError> {
|
||||
self.follow_cell_path_helper(cell_path, insensitive, true)
|
||||
}
|
||||
|
||||
pub fn follow_cell_path_not_from_user_input(
|
||||
self,
|
||||
cell_path: &[PathMember],
|
||||
insensitive: bool,
|
||||
) -> Result<Value, ShellError> {
|
||||
self.follow_cell_path_helper(cell_path, insensitive, false)
|
||||
}
|
||||
|
||||
fn follow_cell_path_helper(
|
||||
self,
|
||||
cell_path: &[PathMember],
|
||||
insensitive: bool,
|
||||
from_user_input: bool,
|
||||
) -> Result<Value, ShellError> {
|
||||
let mut current = self;
|
||||
|
||||
@ -1033,17 +1016,11 @@ impl Value {
|
||||
current = found.1.clone();
|
||||
} else if *optional {
|
||||
return Ok(Value::nothing(*origin_span)); // short-circuit
|
||||
} else if let Some(suggestion) =
|
||||
did_you_mean(val.columns(), column_name)
|
||||
{
|
||||
return Err(ShellError::DidYouMean(suggestion, *origin_span));
|
||||
} else {
|
||||
if from_user_input {
|
||||
if let Some(suggestion) =
|
||||
did_you_mean(val.columns(), column_name)
|
||||
{
|
||||
return Err(ShellError::DidYouMean(
|
||||
suggestion,
|
||||
*origin_span,
|
||||
));
|
||||
}
|
||||
}
|
||||
return Err(ShellError::CantFindColumn {
|
||||
col_name: column_name.to_string(),
|
||||
span: *origin_span,
|
||||
@ -1058,15 +1035,9 @@ impl Value {
|
||||
current = val.get_column_value(column_name)?;
|
||||
} else if *optional {
|
||||
return Ok(Value::nothing(*origin_span)); // short-circuit
|
||||
} else if let Some(suggestion) = did_you_mean(&columns, column_name) {
|
||||
return Err(ShellError::DidYouMean(suggestion, *origin_span));
|
||||
} else {
|
||||
if from_user_input {
|
||||
if let Some(suggestion) = did_you_mean(&columns, column_name) {
|
||||
return Err(ShellError::DidYouMean(
|
||||
suggestion,
|
||||
*origin_span,
|
||||
));
|
||||
}
|
||||
}
|
||||
return Err(ShellError::CantFindColumn {
|
||||
col_name: column_name.to_string(),
|
||||
span: *origin_span,
|
||||
|
Reference in New Issue
Block a user