mirror of
https://github.com/TECHNOFAB11/pay-respects.git
synced 2025-12-11 22:10:09 +01:00
fix: relative path rules
This commit is contained in:
parent
b332ca4dfb
commit
ee7b270d9c
4 changed files with 14 additions and 3 deletions
|
|
@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
- Aliases matching to command-not-found
|
- Aliases matching to command-not-found
|
||||||
- Relative path command fixes
|
- Relative path command fixes
|
||||||
|
- Does not work in `bash` and `zsh`: Not considered a command
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ use crate::shell::{add_candidates_no_dup, module_output, shell_evaluated_command
|
||||||
use crate::style::highlight_difference;
|
use crate::style::highlight_difference;
|
||||||
|
|
||||||
pub fn suggest_candidates(data: &mut Data) {
|
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 command = &data.command;
|
||||||
let privilege = &data.privilege;
|
let privilege = &data.privilege;
|
||||||
let mut suggest_candidates = vec![];
|
let mut suggest_candidates = vec![];
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "pay-respects-utils"
|
name = "pay-respects-utils"
|
||||||
version = "0.1.1"
|
version = "0.1.2"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
# for crates.io
|
# for crates.io
|
||||||
|
|
|
||||||
|
|
@ -76,6 +76,14 @@ pub fn suggest_typo(typos: &[String], candidates: Vec<String>, executables: &[St
|
||||||
if candidates.len() == 1 {
|
if candidates.len() == 1 {
|
||||||
match candidates[0].as_str() {
|
match candidates[0].as_str() {
|
||||||
"path" => {
|
"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)) {
|
if let Some(suggest) = find_similar(typo, executables, Some(2)) {
|
||||||
suggestions.push(suggest);
|
suggestions.push(suggest);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -89,7 +97,9 @@ pub fn suggest_typo(typos: &[String], candidates: Vec<String>, executables: &[St
|
||||||
suggestions.push(typo.to_string());
|
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)) {
|
} else if let Some(suggest) = find_similar(typo, &candidates, Some(2)) {
|
||||||
suggestions.push(suggest);
|
suggestions.push(suggest);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue