diff --git a/app/src/executor.rs b/app/src/executor.rs index 5ae786e7..46069276 100644 --- a/app/src/executor.rs +++ b/app/src/executor.rs @@ -1,4 +1,4 @@ -use core::{files::FilesSort, input::InputMode}; +use core::{emit, files::FilesSort, input::InputMode}; use std::path::PathBuf; use config::{keymap::{Control, Exec, Key, KeymapLayer}, manager::SortBy, KEYMAP}; @@ -67,8 +67,12 @@ impl Executor { "forward" => cx.manager.active_mut().forward(), "cd" => { let path = exec.args.get(0).map(PathBuf::from).unwrap_or_default(); - let interactive = exec.named.contains_key("interactive"); - cx.manager.active_mut().cd_interactive(interactive, path) + if exec.named.contains_key("interactive") { + cx.manager.active_mut().cd_interactive(path) + } else { + emit!(Cd(path)); + false + } } // Selection diff --git a/core/src/manager/tab.rs b/core/src/manager/tab.rs index 4138a256..9124c995 100644 --- a/core/src/manager/tab.rs +++ b/core/src/manager/tab.rs @@ -74,24 +74,6 @@ impl Tab { true } - pub fn cd_interactive(&mut self, interactive: bool, target: PathBuf) -> bool { - if interactive { - tokio::spawn(async move { - let result = emit!(Input(InputOpt::top("Path:").with_value(target.to_string_lossy()))); - - if let Ok(path) = result.await { - let path = PathBuf::from(path); - emit!(Cd(path)); - } - Ok::<(), Error>(()) - }); - } - else { - emit!(Cd(target)); - } - false - } - pub async fn cd(&mut self, mut target: PathBuf) -> bool { let file = if let Ok(f) = File::from(&target).await { f @@ -133,6 +115,18 @@ impl Tab { true } + pub fn cd_interactive(&mut self, target: PathBuf) -> bool { + tokio::spawn(async move { + let result = + emit!(Input(InputOpt::top("Change directory:").with_value(target.to_string_lossy()))); + + if let Ok(target) = result.await { + emit!(Cd(PathBuf::from(target))); + } + }); + false + } + pub fn enter(&mut self) -> bool { let hovered = if let Some(ref h) = self.current.hovered { h.clone()