diff options
author | Jiayi Zhao <jeff.no.zhao@gmail.com> | 2020-08-30 15:20:03 -0400 |
---|---|---|
committer | Jiayi Zhao <jeff.no.zhao@gmail.com> | 2020-08-30 15:20:03 -0400 |
commit | e7218c81d90ae07d7f56dce0c3032db15b11d118 (patch) | |
tree | 63c3b63345ec73031b26c1b900957ad06b69aec6 /src/commands/delete_files.rs | |
parent | a592bfe51c0cbb7744f14586520827cb06da8c8d (diff) |
rework and fix issues
- fixed bug where io tasks would not run when user is in a textfield or prompt
- fixed bug where cut doesn't work
- rework structs to have private fields and public functions
- move IOWorkerObserver into seperate file
- move code from TuiView to TuiFolderView
Diffstat (limited to 'src/commands/delete_files.rs')
-rw-r--r-- | src/commands/delete_files.rs | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/commands/delete_files.rs b/src/commands/delete_files.rs index 69069fe..25a13f8 100644 --- a/src/commands/delete_files.rs +++ b/src/commands/delete_files.rs @@ -22,7 +22,10 @@ impl DeleteFiles { "delete_files" } - pub fn remove_files(paths: &[&path::Path]) -> std::io::Result<()> { + pub fn remove_files<'a, I>(paths: I) -> std::io::Result<()> + where + I: Iterator<Item = &'a path::Path>, + { for path in paths { if let Ok(metadata) = fs::symlink_metadata(path) { if metadata.is_dir() { @@ -53,7 +56,7 @@ impl DeleteFiles { let ch = { let prompt_str = format!("Delete {} files? (Y/n)", paths_len); let mut prompt = TuiPrompt::new(&prompt_str); - prompt.get_key(backend, &context) + prompt.get_key(backend, context) }; if ch == Key::Char('y') || ch == Key::Char('\n') { @@ -61,19 +64,19 @@ impl DeleteFiles { let ch = { let prompt_str = "Are you sure? (y/N)"; let mut prompt = TuiPrompt::new(prompt_str); - prompt.get_key(backend, &context) + prompt.get_key(backend, context) }; if ch == Key::Char('y') { - Self::remove_files(&paths)?; + Self::remove_files(paths.iter().map(|p| p.as_path()))?; ReloadDirList::reload(tab_index, context)?; let msg = format!("Deleted {} files", paths_len); - context.message_queue.push_back(msg); + context.push_msg(msg); } } else { - Self::remove_files(&paths)?; + Self::remove_files(paths.iter().map(|p| p.as_path()))?; ReloadDirList::reload(tab_index, context)?; let msg = format!("Deleted {} files", paths_len); - context.message_queue.push_back(msg); + context.push_msg(msg); } } Ok(()) @@ -95,7 +98,7 @@ impl JoshutoRunnable for DeleteFiles { let options = context.config_t.sort_option.clone(); let curr_path = context.tab_context_ref().curr_tab_ref().pwd().to_path_buf(); for tab in context.tab_context_mut().iter_mut() { - tab.history.reload(&curr_path, &options)?; + tab.history_mut().reload(&curr_path, &options)?; } LoadChild::load_child(context)?; Ok(()) |