summaryrefslogtreecommitdiffstats
path: root/src/verb/verb_store.rs
diff options
context:
space:
mode:
authorCanop <cano.petrole@gmail.com>2022-05-21 20:16:53 +0200
committerCanop <cano.petrole@gmail.com>2022-05-21 20:16:53 +0200
commitaad26d76bbf1eb9a252dad11de9edc8ba172b281 (patch)
tree154370c372633a6429801916e15f936fb5424059 /src/verb/verb_store.rs
parent70f4d09aab75c7610e34bde855f4cd28ce691954 (diff)
allow verbs with extension filter before other ones
Verbs tried in order, the first ones may have extension filters and another one without filter would catch everything. Fix #552
Diffstat (limited to 'src/verb/verb_store.rs')
-rw-r--r--src/verb/verb_store.rs22
1 files changed, 7 insertions, 15 deletions
diff --git a/src/verb/verb_store.rs b/src/verb/verb_store.rs
index 2cf5628..db95e49 100644
--- a/src/verb/verb_store.rs
+++ b/src/verb/verb_store.rs
@@ -33,20 +33,12 @@ pub enum PrefixSearchResult<'v, T> {
impl VerbStore {
pub fn new(conf: &mut Conf) -> Result<Self, ConfError> {
- // we start with the builtin verbs so that a verb from configuration
- // can refer to a built-in
- let mut verbs = builtin_verbs();
-
+ let mut verbs = Vec::new();
for vc in &conf.verbs {
let verb = vc.make_verb(&verbs)?;
verbs.push(verb);
}
-
- // We reverse the array as we'll search in order.
- // This way, a user can overload a standard verb, or a standard
- // shortcut.
- verbs.reverse();
-
+ verbs.append(&mut builtin_verbs()); // at the end so that we can override them
Ok(Self { verbs })
}
@@ -91,6 +83,11 @@ impl VerbStore {
continue;
}
}
+ if !verb.file_extensions.is_empty() {
+ if !extension.map_or(false, |ext| verb.file_extensions.iter().any(|ve| ve == ext)) {
+ continue;
+ }
+ }
for name in &verb.names {
if name.starts_with(prefix) {
if name == prefix {
@@ -102,11 +99,6 @@ impl VerbStore {
continue;
}
}
- if !verb.file_extensions.is_empty() {
- if !extension.map_or(false, |ext| verb.file_extensions.iter().any(|ve| ve == ext)) {
- continue;
- }
- }
}
match nb_found {
0 => PrefixSearchResult::NoMatch,