summaryrefslogtreecommitdiffstats
path: root/src/verb/verb_store.rs
diff options
context:
space:
mode:
authorCanop <cano.petrole@gmail.com>2020-05-04 22:08:36 +0200
committerCanop <cano.petrole@gmail.com>2020-05-04 22:08:36 +0200
commita0ed4966a4afa9af4044f3bf303b442bfccb46fd (patch)
tree173a73135ea72a71d81e6b8f8d7ce001a5f008b3 /src/verb/verb_store.rs
parentc1dcc8124bf9ce0de8e9fbe94c02706ec4b8b108 (diff)
internals can accept an argument. :focus does accept one
Both in input and in configuration. This allowed to remove the :focus_user_home and :focus_root internals. It's now possible to define a verb like ``` [[verbs]] key = "ctrl-h" invocation = "home" execution = ":focus ~/dev" ``` which can be called as ctrl-h, :home, but also :!home (in order to open the ~/dev directory in a new panel)
Diffstat (limited to 'src/verb/verb_store.rs')
-rw-r--r--src/verb/verb_store.rs16
1 files changed, 4 insertions, 12 deletions
diff --git a/src/verb/verb_store.rs b/src/verb/verb_store.rs
index 9bfeefd..448b3e0 100644
--- a/src/verb/verb_store.rs
+++ b/src/verb/verb_store.rs
@@ -48,25 +48,17 @@ impl VerbStore {
let mut nb_found = 0;
let mut completions: Vec<&str> = Vec::new();
for (index, verb) in self.verbs.iter().enumerate() {
- if let Some(shortcut) = &verb.shortcut {
- if shortcut.starts_with(prefix) {
- if shortcut == prefix {
+ for name in &verb.names {
+ if name.starts_with(prefix) {
+ if name == prefix {
return PrefixSearchResult::Match(&verb);
}
found_index = index;
nb_found += 1;
- completions.push(&shortcut);
+ completions.push(name);
continue;
}
}
- if verb.name.starts_with(prefix) {
- if verb.name == prefix {
- return PrefixSearchResult::Match(&verb);
- }
- found_index = index;
- nb_found += 1;
- completions.push(&verb.name);
- }
}
match nb_found {
0 => PrefixSearchResult::NoMatch,