diff options
Diffstat (limited to 'src/completion.rs')
-rw-r--r-- | src/completion.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/completion.rs b/src/completion.rs index 6894bb8..a4733ae 100644 --- a/src/completion.rs +++ b/src/completion.rs @@ -1,5 +1,7 @@ use std::fs::{self, ReadDir}; +use strum::IntoEnumIterator; + use crate::fileinfo::PathContent; use crate::fm_error::FmResult; use crate::mode::Mode; @@ -17,6 +19,8 @@ pub enum InputCompleted { Search, /// Complete an executable name from $PATH Exec, + /// Command + Command, } /// Holds a `Vec<String>` of possible completions and an `usize` index @@ -158,6 +162,20 @@ impl Completion { Ok(()) } + pub fn command(&mut self, input_string: &str) -> FmResult<()> { + let proposals = crate::action_map::ActionMap::iter() + .filter(|command| { + command + .to_string() + .to_lowercase() + .contains(&input_string.to_lowercase()) + }) + .map(|command| command.to_string()) + .collect(); + self.update(proposals); + Ok(()) + } + fn find_completion_in_path( path: std::path::PathBuf, input_string: &str, |