diff --git a/module-runtime-rules/src/replaces.rs b/module-runtime-rules/src/replaces.rs index 9518c1c..469bd22 100644 --- a/module-runtime-rules/src/replaces.rs +++ b/module-runtime-rules/src/replaces.rs @@ -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) { +pub fn exes( + suggest: &mut String, + split_command: &[String], + executables: &[String], + exes_list: &mut Vec, +) { if suggest.contains("{{exes") { let (placeholder, args) = eval_placeholder(suggest, "{{exes", "}}"); diff --git a/module-runtime-rules/src/rules.rs b/module-runtime-rules/src/rules.rs index 94a6b5f..2524206 100644 --- a/module-runtime-rules/src/rules.rs +++ b/module-runtime-rules/src/rules.rs @@ -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 { - #[cfg(windows)] let xdg_config_home = std::env::var("APPDATA").unwrap(); #[cfg(not(windows))] @@ -181,7 +181,8 @@ fn get_rule(executable: &str) -> Option { 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::>(); @@ -190,7 +191,7 @@ fn get_rule(executable: &str) -> Option { } let xdg_data_dirs = - std::env::var("XDG_DATA_DIRS").unwrap_or("/usr/local/share:/usr/share".to_owned()); + std::env::var("XDG_DATA_DIRS").unwrap_or("/usr/local/share:/usr/share".to_owned()); let xdg_data_dirs = xdg_data_dirs.split(':').collect::>(); if let Some(file) = check_dirs(&xdg_data_dirs) { diff --git a/parser/src/replaces.rs b/parser/src/replaces.rs index 18b4871..47ff422 100644 --- a/parser/src/replaces.rs +++ b/parser/src/replaces.rs @@ -249,7 +249,6 @@ pub fn exes(suggest: &mut String, exes_list: &mut Vec) { } } else { unreachable!("Exes suggestion does not support range"); - } } else { unreachable!("Exes suggestion must have a command index"); diff --git a/utils/src/evals.rs b/utils/src/evals.rs index bea2b29..2e3d9a7 100644 --- a/utils/src/evals.rs +++ b/utils/src/evals.rs @@ -138,7 +138,11 @@ pub fn find_similar(typo: &str, candidates: &[String], threshold: Option) None } -pub fn find_similars(typo: &str, candidates: &[String], threshold: Option) -> Option> { +pub fn find_similars( + typo: &str, + candidates: &[String], + threshold: Option, +) -> Option> { 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 } } 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 }