diff options
author | Jiayi Zhao <jeff.no.zhao@gmail.com> | 2020-03-14 10:33:00 -0400 |
---|---|---|
committer | Jiayi Zhao <jeff.no.zhao@gmail.com> | 2020-03-14 10:33:00 -0400 |
commit | 18ddb386325e9a017df45825ace6d667c90ac3e5 (patch) | |
tree | 469505bb06b44083bf5282a3b0bf8ff6487efff3 /src/commands | |
parent | 59ebe918aa4d6753cf061f08b38b84a9d11640e1 (diff) |
update preview when file operations finish
Diffstat (limited to 'src/commands')
-rw-r--r-- | src/commands/delete_files.rs | 3 | ||||
-rw-r--r-- | src/commands/file_ops/paste_copy.rs | 8 | ||||
-rw-r--r-- | src/commands/file_ops/paste_cut.rs | 8 | ||||
-rw-r--r-- | src/commands/rename_file.rs | 4 | ||||
-rw-r--r-- | src/commands/tab_operations.rs | 3 |
5 files changed, 19 insertions, 7 deletions
diff --git a/src/commands/delete_files.rs b/src/commands/delete_files.rs index 30a5754..9e302b0 100644 --- a/src/commands/delete_files.rs +++ b/src/commands/delete_files.rs @@ -3,7 +3,7 @@ use std::path; use termion::event::Key; -use crate::commands::{JoshutoCommand, JoshutoRunnable, ReloadDirList}; +use crate::commands::{CursorMoveStub, JoshutoCommand, JoshutoRunnable, ReloadDirList}; use crate::context::JoshutoContext; use crate::error::JoshutoResult; use crate::ui::TuiBackend; @@ -90,6 +90,7 @@ impl std::fmt::Display for DeleteFiles { impl JoshutoRunnable for DeleteFiles { fn execute(&self, context: &mut JoshutoContext, backend: &mut TuiBackend) -> JoshutoResult<()> { Self::delete_files(context, backend)?; + CursorMoveStub::new().execute(context, backend)?; Ok(()) } } diff --git a/src/commands/file_ops/paste_copy.rs b/src/commands/file_ops/paste_copy.rs index 26f0e5c..943e14f 100644 --- a/src/commands/file_ops/paste_copy.rs +++ b/src/commands/file_ops/paste_copy.rs @@ -44,7 +44,9 @@ pub fn paste_copy( } let tab_dest = context.curr_tab_index; - let dest = context.tabs[tab_dest].curr_path.clone(); + let thread_dest = context.tabs[tab_dest].curr_path.clone(); + let dest = thread_dest.clone(); + let src = paths[0].parent().unwrap().to_path_buf(); let (tx_start, rx_start) = mpsc::channel(); let (tx, rx) = mpsc::channel(); @@ -52,13 +54,15 @@ pub fn paste_copy( let mut total = 0; rx_start.recv(); for path in paths { - total += recursive_copy(dest.as_path(), path.as_path(), &options)?; + total += recursive_copy(thread_dest.as_path(), path.as_path(), &options)?; tx.send(Event::IOWorkerProgress(total)); } Ok(total) }); let thread = IOWorkerThread { + src, + dest, handle, tx_start, rx, diff --git a/src/commands/file_ops/paste_cut.rs b/src/commands/file_ops/paste_cut.rs index 1177f12..3d1b610 100644 --- a/src/commands/file_ops/paste_cut.rs +++ b/src/commands/file_ops/paste_cut.rs @@ -52,7 +52,9 @@ pub fn paste_cut( } let tab_dest = context.curr_tab_index; - let dest = context.tabs[tab_dest].curr_path.clone(); + let thread_dest = context.tabs[tab_dest].curr_path.clone(); + let dest = thread_dest.clone(); + let src = paths[0].parent().unwrap().to_path_buf(); let (tx_start, rx_start) = mpsc::channel(); let (tx, rx) = mpsc::channel(); @@ -60,13 +62,15 @@ pub fn paste_cut( let mut total = 0; rx_start.recv(); for path in paths { - total += recursive_cut(dest.as_path(), path.as_path(), &options)?; + total += recursive_cut(thread_dest.as_path(), path.as_path(), &options)?; tx.send(Event::IOWorkerProgress(total)); } Ok(total) }); let thread = IOWorkerThread { + src, + dest, handle, tx_start, rx, diff --git a/src/commands/rename_file.rs b/src/commands/rename_file.rs index 5078680..7ee4272 100644 --- a/src/commands/rename_file.rs +++ b/src/commands/rename_file.rs @@ -1,6 +1,6 @@ use std::path; -use crate::commands::{CommandLine, JoshutoCommand, JoshutoRunnable}; +use crate::commands::{CommandLine, CursorMoveStub, JoshutoCommand, JoshutoRunnable}; use crate::context::JoshutoContext; use crate::error::JoshutoResult; use crate::ui::TuiBackend; @@ -59,6 +59,7 @@ impl JoshutoRunnable for RenameFile { if let Some(path) = path { self.rename_file(&path, context)?; } + CursorMoveStub::new().execute(context, backend)?; Ok(()) } } @@ -116,6 +117,7 @@ impl JoshutoRunnable for RenameFileAppend { if let Some(file_name) = file_name { self.rename_file(context, backend, file_name.as_str())?; } + Ok(()) } } diff --git a/src/commands/tab_operations.rs b/src/commands/tab_operations.rs index c2bdbab..673502b 100644 --- a/src/commands/tab_operations.rs +++ b/src/commands/tab_operations.rs @@ -1,6 +1,6 @@ use std::path; -use crate::commands::{JoshutoCommand, JoshutoRunnable, Quit, TabSwitch}; +use crate::commands::{JoshutoCommand, JoshutoRunnable, CursorMoveStub, Quit, TabSwitch}; use crate::context::JoshutoContext; use crate::error::JoshutoResult; use crate::tab::JoshutoTab; @@ -30,6 +30,7 @@ impl NewTab { context.tabs.push(tab); context.curr_tab_index = context.tabs.len() - 1; TabSwitch::tab_switch(context.curr_tab_index, context)?; + CursorMoveStub::new().execute(context, backend)?; Ok(()) } } |