From 8b82d0931850d9494c672d191713eda238814798 Mon Sep 17 00:00:00 2001 From: Kristofers Solo Date: Thu, 10 Jul 2025 13:46:48 +0300 Subject: [PATCH] fix(move): path pre-population --- src/app/mod.rs | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/app/mod.rs b/src/app/mod.rs index e8595d3..cb55e59 100644 --- a/src/app/mod.rs +++ b/src/app/mod.rs @@ -170,7 +170,8 @@ impl<'a> App<'a> { pub fn prepare_move_action(&mut self) { if let Some(download_dir) = self.get_current_downlaod_dir() { - self.set_input_from_path(&download_dir); + let path_buf = PathBuf::from(download_dir); + self.update_cursor(path_buf); } self.input_mode = true; } @@ -227,27 +228,19 @@ impl<'a> App<'a> { } } - fn get_current_downlaod_dir(&self) -> Option { + fn get_current_downlaod_dir(&self) -> Option { match self.selected(true) { Selected::Current(current_id) => self .torrents .torrents .iter() .find(|&t| t.id == Some(current_id)) - .and_then(|t| t.download_dir.clone()), + .and_then(|t| t.download_dir.as_ref()) + .map(PathBuf::from), _ => None, } } - fn set_input_from_path(&mut self, download_dir: &str) { - let mut path_buf = PathBuf::from(download_dir); - - if path_buf.is_dir() && !download_dir.ends_with('/') { - path_buf.push("/"); - } - self.update_cursor(path_buf); - } - fn update_cursor(&mut self, path: PathBuf) { self.input = path.to_string_lossy().to_string(); self.cursor_position = self.input.len();