summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorqkzk <qu3nt1n@gmail.com>2022-10-30 22:12:55 +0100
committerqkzk <qu3nt1n@gmail.com>2022-10-30 22:12:55 +0100
commitee828e77c0b3e28d2b006543ac65a6637825c0b3 (patch)
tree752453ffbe8e86c3319213cae6fd63b95e43c480 /src
parentafb085c689d491501f9c8da2e663cf8bb7b7a1b1 (diff)
reset completion when entering normal mode
Diffstat (limited to 'src')
-rw-r--r--src/tab.rs19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/tab.rs b/src/tab.rs
index eea42be..06d0dc1 100644
--- a/src/tab.rs
+++ b/src/tab.rs
@@ -105,6 +105,7 @@ impl Tab {
pub fn event_normal(&mut self) -> FmResult<()> {
self.input.reset();
+ self.completion.reset();
self.path_content.reset_files()?;
self.window.reset(self.path_content.files.len());
self.mode = Mode::Normal;
@@ -538,18 +539,16 @@ impl Tab {
let exec_command = self.input.string.clone();
let mut args: Vec<&str> = exec_command.split(' ').collect();
let command = args.remove(0);
- if !std::path::Path::new(command).exists() {
- eprintln!("File {} doesn't exist.", command);
- return Ok(());
+ if std::path::Path::new(command).exists() {
+ let path = &self
+ .path_content
+ .selected_path_str()
+ .ok_or_else(|| FmError::new("path unreachable"))?;
+ args.push(path);
+ execute_in_child(command, &args)?;
}
-
- let path = &self
- .path_content
- .selected_path_str()
- .ok_or_else(|| FmError::new("path unreachable"))?;
- args.push(path);
+ self.completion.reset();
self.input.reset();
- execute_in_child(command, &args)?;
Ok(())
}