forked from extern/nushell
Don't compute 'did you mean' suggestions unless showing them to user (#6540)
This commit is contained in:
parent
4926865c4e
commit
367f79cb4f
@ -336,7 +336,7 @@ fn get_converted_value(
|
||||
val: block_id,
|
||||
span: from_span,
|
||||
..
|
||||
}) = env_conversions.follow_cell_path(path_members, false)
|
||||
}) = env_conversions.follow_cell_path_not_from_user_input(path_members, false)
|
||||
{
|
||||
let block = engine_state.get_block(block_id);
|
||||
|
||||
|
@ -609,6 +609,23 @@ 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;
|
||||
for member in cell_path {
|
||||
@ -673,9 +690,12 @@ impl Value {
|
||||
}
|
||||
}) {
|
||||
current = found.1.clone();
|
||||
} else if let Some(suggestion) = did_you_mean(&cols, column_name) {
|
||||
return Err(ShellError::DidYouMean(suggestion, *origin_span));
|
||||
} else {
|
||||
if from_user_input {
|
||||
if let Some(suggestion) = did_you_mean(&cols, column_name) {
|
||||
return Err(ShellError::DidYouMean(suggestion, *origin_span));
|
||||
}
|
||||
}
|
||||
return Err(ShellError::CantFindColumn(*origin_span, span));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user