mirror of
https://github.com/nushell/nushell.git
synced 2025-03-30 10:37:29 +02:00
Check same-string-different-case in did_you_mean (#4991)
This commit is contained in:
parent
ee5064abed
commit
0011f4df56
@ -360,6 +360,15 @@ impl From<Box<dyn std::error::Error + Send + Sync>> for ShellError {
|
||||
}
|
||||
|
||||
pub fn did_you_mean(possibilities: &[String], tried: &str) -> Option<String> {
|
||||
// First see if we can find the same string just cased differently
|
||||
let great_match_index = possibilities
|
||||
.iter()
|
||||
.position(|word| word.to_lowercase() == tried.to_lowercase());
|
||||
|
||||
if let Some(index) = great_match_index {
|
||||
return Some(possibilities[index].to_owned());
|
||||
}
|
||||
|
||||
let mut possible_matches: Vec<_> = possibilities
|
||||
.iter()
|
||||
.map(|word| {
|
||||
|
Loading…
Reference in New Issue
Block a user