From d044164f264cf300d98d163a960cb42a50810a10 Mon Sep 17 00:00:00 2001 From: iff Date: Fri, 3 Jan 2025 15:25:18 +0100 Subject: [PATCH] chore: prioritize module suggestions --- core/src/suggestions.rs | 24 ++++++++++++------------ modules.md | 2 +- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/core/src/suggestions.rs b/core/src/suggestions.rs index 4bdb733..62ccac5 100644 --- a/core/src/suggestions.rs +++ b/core/src/suggestions.rs @@ -21,18 +21,6 @@ pub fn suggest_candidates(data: &mut Data) { let modules = &data.modules; let fallbacks = &data.fallbacks; - if privilege.is_none() { - if let Some(candidates) = match_pattern("_PR_privilege", data) { - add_candidates_no_dup(command, &mut suggest_candidates, &candidates); - } - } - if let Some(candidates) = match_pattern(executable, data) { - add_candidates_no_dup(command, &mut suggest_candidates, &candidates); - } - if let Some(candidates) = match_pattern("_PR_general", data) { - add_candidates_no_dup(command, &mut suggest_candidates, &candidates); - } - #[cfg(debug_assertions)] { eprintln!("modules: {modules:?}"); @@ -47,6 +35,18 @@ pub fn suggest_candidates(data: &mut Data) { } } + if privilege.is_none() { + if let Some(candidates) = match_pattern("_PR_privilege", data) { + add_candidates_no_dup(command, &mut suggest_candidates, &candidates); + } + } + if let Some(candidates) = match_pattern(executable, data) { + add_candidates_no_dup(command, &mut suggest_candidates, &candidates); + } + if let Some(candidates) = match_pattern("_PR_general", data) { + add_candidates_no_dup(command, &mut suggest_candidates, &candidates); + } + if !suggest_candidates.is_empty() { data.candidates = suggest_candidates; return; diff --git a/modules.md b/modules.md index 5f14d9d..82898fa 100644 --- a/modules.md +++ b/modules.md @@ -22,7 +22,7 @@ There are 2 types of modules: - **CAUTION**: Will immediately return if a suggestion is obtained - Naming convention: `_pay-respects-fallback--` -Priority is used to retrieve suggestions in a specific order by an [unstable sort](https://doc.rust-lang.org/std/primitive.slice.html#method.sort_unstable) (although they will always be after compile-time matches). Default modules have a priority of `100`. +Priority is used to retrieve suggestions in a specific order by an [unstable sort](https://doc.rust-lang.org/std/primitive.slice.html#method.sort_unstable). Default modules have a priority of `100`. When running your module, you will get the following environment variables: