mirror of
https://github.com/TECHNOFAB11/pay-respects.git
synced 2025-12-11 22:10:09 +01:00
chore: cleanup
This commit is contained in:
parent
3460d66aac
commit
ecdcee5969
4 changed files with 22 additions and 8 deletions
|
|
@ -175,7 +175,12 @@ pub fn typo(suggest: &mut String, split_command: &[String], executables: &[Strin
|
|||
}
|
||||
}
|
||||
|
||||
pub fn exes(suggest: &mut String, split_command: &[String], executables: &[String], exes_list: &mut Vec<String>) {
|
||||
pub fn exes(
|
||||
suggest: &mut String,
|
||||
split_command: &[String],
|
||||
executables: &[String],
|
||||
exes_list: &mut Vec<String>,
|
||||
) {
|
||||
if suggest.contains("{{exes") {
|
||||
let (placeholder, args) = eval_placeholder(suggest, "{{exes", "}}");
|
||||
|
||||
|
|
|
|||
|
|
@ -83,7 +83,8 @@ pub fn runtime_match(
|
|||
if pure_suggest.contains("{{command}}") {
|
||||
pure_suggest = pure_suggest.replace("{{command}}", last_command);
|
||||
}
|
||||
let suggests = eval_suggest(&pure_suggest, last_command, error_msg, executables, shell);
|
||||
let suggests =
|
||||
eval_suggest(&pure_suggest, last_command, error_msg, executables, shell);
|
||||
for suggest in suggests {
|
||||
print!("{}", suggest);
|
||||
print!("<_PR_BR>");
|
||||
|
|
@ -159,7 +160,6 @@ fn eval_suggest(
|
|||
}
|
||||
|
||||
fn get_rule(executable: &str) -> Option<String> {
|
||||
|
||||
#[cfg(windows)]
|
||||
let xdg_config_home = std::env::var("APPDATA").unwrap();
|
||||
#[cfg(not(windows))]
|
||||
|
|
@ -181,7 +181,8 @@ fn get_rule(executable: &str) -> Option<String> {
|
|||
return Some(file);
|
||||
}
|
||||
|
||||
#[cfg(not(windows))] {
|
||||
#[cfg(not(windows))]
|
||||
{
|
||||
let xdg_config_dirs = std::env::var("XDG_CONFIG_DIRS").unwrap_or("/etc/xdg".to_owned());
|
||||
let xdg_config_dirs = xdg_config_dirs.split(':').collect::<Vec<&str>>();
|
||||
|
||||
|
|
|
|||
|
|
@ -249,7 +249,6 @@ pub fn exes(suggest: &mut String, exes_list: &mut Vec<TokenStream2>) {
|
|||
}
|
||||
} else {
|
||||
unreachable!("Exes suggestion does not support range");
|
||||
|
||||
}
|
||||
} else {
|
||||
unreachable!("Exes suggestion must have a command index");
|
||||
|
|
|
|||
|
|
@ -138,7 +138,11 @@ pub fn find_similar(typo: &str, candidates: &[String], threshold: Option<usize>)
|
|||
None
|
||||
}
|
||||
|
||||
pub fn find_similars(typo: &str, candidates: &[String], threshold: Option<usize>) -> Option<Vec<String>> {
|
||||
pub fn find_similars(
|
||||
typo: &str,
|
||||
candidates: &[String],
|
||||
threshold: Option<usize>,
|
||||
) -> Option<Vec<String>> {
|
||||
let threshold = threshold.unwrap_or(2);
|
||||
let mut min_distance = typo.chars().count() / threshold + 1;
|
||||
let mut min_distance_index = vec![];
|
||||
|
|
@ -156,7 +160,12 @@ pub fn find_similars(typo: &str, candidates: &[String], threshold: Option<usize>
|
|||
}
|
||||
}
|
||||
if !min_distance_index.is_empty() {
|
||||
return Some(min_distance_index.iter().map(|&i| candidates[i].to_string()).collect());
|
||||
return Some(
|
||||
min_distance_index
|
||||
.iter()
|
||||
.map(|&i| candidates[i].to_string())
|
||||
.collect(),
|
||||
);
|
||||
}
|
||||
None
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue