diff --git a/CHANGELOG.md b/CHANGELOG.md index c99c0e1..5eb3076 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Aliases matching to command-not-found - Relative path command fixes + - Does not work in `bash` and `zsh`: Not considered a command ### Changed diff --git a/core/src/suggestions.rs b/core/src/suggestions.rs index affb080..272bd48 100644 --- a/core/src/suggestions.rs +++ b/core/src/suggestions.rs @@ -10,7 +10,7 @@ use crate::shell::{add_candidates_no_dup, module_output, shell_evaluated_command use crate::style::highlight_difference; pub fn suggest_candidates(data: &mut Data) { - let executable = &data.split[0]; + let executable = &data.split[0].rsplit(std::path::MAIN_SEPARATOR).next().unwrap(); let command = &data.command; let privilege = &data.privilege; let mut suggest_candidates = vec![]; diff --git a/utils/Cargo.toml b/utils/Cargo.toml index 546cfe8..db7470b 100644 --- a/utils/Cargo.toml +++ b/utils/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pay-respects-utils" -version = "0.1.1" +version = "0.1.2" edition = "2021" # for crates.io diff --git a/utils/src/evals.rs b/utils/src/evals.rs index 1a6ef13..c2ade66 100644 --- a/utils/src/evals.rs +++ b/utils/src/evals.rs @@ -76,6 +76,14 @@ pub fn suggest_typo(typos: &[String], candidates: Vec, executables: &[St if candidates.len() == 1 { match candidates[0].as_str() { "path" => { + if typo.contains(std::path::MAIN_SEPARATOR) { + if let Some(suggest) = best_match_file(typo) { + suggestions.push(suggest); + } else { + suggestions.push(typo.to_string()); + } + continue; + } if let Some(suggest) = find_similar(typo, executables, Some(2)) { suggestions.push(suggest); } else { @@ -89,7 +97,9 @@ pub fn suggest_typo(typos: &[String], candidates: Vec, executables: &[St suggestions.push(typo.to_string()); } } - _ => {} + _ => { + unreachable!("suggest_typo: must have at least two candidates") + } } } else if let Some(suggest) = find_similar(typo, &candidates, Some(2)) { suggestions.push(suggest);