mirror of
https://github.com/nushell/nushell
synced 2024-12-27 05:23:11 +00:00
Don't compute 'did you mean' suggestions unless showing them to user (#6540)
This commit is contained in:
parent
4926865c4e
commit
367f79cb4f
2 changed files with 23 additions and 3 deletions
|
@ -336,7 +336,7 @@ fn get_converted_value(
|
||||||
val: block_id,
|
val: block_id,
|
||||||
span: from_span,
|
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);
|
let block = engine_state.get_block(block_id);
|
||||||
|
|
||||||
|
|
|
@ -609,6 +609,23 @@ impl Value {
|
||||||
self,
|
self,
|
||||||
cell_path: &[PathMember],
|
cell_path: &[PathMember],
|
||||||
insensitive: bool,
|
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> {
|
) -> Result<Value, ShellError> {
|
||||||
let mut current = self;
|
let mut current = self;
|
||||||
for member in cell_path {
|
for member in cell_path {
|
||||||
|
@ -673,9 +690,12 @@ impl Value {
|
||||||
}
|
}
|
||||||
}) {
|
}) {
|
||||||
current = found.1.clone();
|
current = found.1.clone();
|
||||||
} else if let Some(suggestion) = did_you_mean(&cols, column_name) {
|
|
||||||
return Err(ShellError::DidYouMean(suggestion, *origin_span));
|
|
||||||
} else {
|
} 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));
|
return Err(ShellError::CantFindColumn(*origin_span, span));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue