diff --git a/src/app/mod.rs b/src/app/mod.rs index 9551cd6..e57d5a7 100644 --- a/src/app/mod.rs +++ b/src/app/mod.rs @@ -151,6 +151,23 @@ impl<'a> App<'a> { Ok(()) } + pub fn prepare_move_action(&mut self) { + if let Selected::Current(current_id) = self.selected(true) { + if let Some(torrent) = self + .torrents + .torrents + .iter() + .find(|t| t.id == Some(current_id)) + { + if let Some(download_dir) = &torrent.download_dir { + self.input = download_dir.clone(); + self.cursor_position = self.input.len(); + } + } + } + self.input_mode = true; + } + pub fn select(&mut self) { if let Selected::Current(current_id) = self.selected(true) { if self.torrents.selected.contains(¤t_id) { diff --git a/src/handler.rs b/src/handler.rs index 3e41fbb..9d4357b 100644 --- a/src/handler.rs +++ b/src/handler.rs @@ -78,7 +78,7 @@ pub async fn update(app: &mut App<'_>, action: Action) -> Result<()> { Action::ToggleAll => app.torrents.toggle_all().await?, Action::PauseAll => app.torrents.stop_all().await?, Action::StartAll => app.torrents.start_all().await?, - Action::Move => app.input_mode = true, + Action::Move => app.prepare_move_action(), Action::Delete(x) => app.delete(x).await?, Action::Rename => unimplemented!(), Action::Select => app.select(),