diff options
author | Jiayi Zhao <jeff.no.zhao@gmail.com> | 2020-08-29 22:06:19 -0400 |
---|---|---|
committer | Jiayi Zhao <jeff.no.zhao@gmail.com> | 2020-08-29 22:08:23 -0400 |
commit | 5be4a5f472655a76e1430bad09a19f6ad111e474 (patch) | |
tree | 1fcffa6c8d37cc6d538b29b6fbd773e8de58512d /src/commands/rename_file.rs | |
parent | 4f3842b56f1729dcd8e81c77f98253ed9dfb23b3 (diff) |
big rework and dependency update
- abstract JoshutoContext implementation behind functions
- rework io workers in an attempt to fix a bug
- update dependencies
- remove JoshutoContextWorker
Diffstat (limited to 'src/commands/rename_file.rs')
-rw-r--r-- | src/commands/rename_file.rs | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/commands/rename_file.rs b/src/commands/rename_file.rs index f8bb5c6..8581c14 100644 --- a/src/commands/rename_file.rs +++ b/src/commands/rename_file.rs @@ -31,9 +31,9 @@ impl RenameFile { return Err(err); } std::fs::rename(&path, &new_path)?; - let curr_tab = &mut context.tabs[context.curr_tab_index]; - if let Some(curr_list) = curr_tab.curr_list_mut() { - curr_list.reload_contents(&context.config_t.sort_option)?; + let options = context.config_t.sort_option.clone(); + if let Some(curr_list) = context.tab_context_mut().curr_tab_mut().curr_list_mut() { + curr_list.reload_contents(&options)?; } Ok(()) } @@ -51,10 +51,13 @@ impl JoshutoRunnable for RenameFile { fn execute(&self, context: &mut JoshutoContext, _: &mut TuiBackend) -> JoshutoResult<()> { let mut path: Option<path::PathBuf> = None; - if let Some(curr_list) = context.curr_tab_ref().curr_list_ref() { - if let Some(s) = curr_list.get_curr_ref() { - path = Some(s.file_path().clone()); - } + if let Some(s) = context + .tab_context_ref() + .curr_tab_ref() + .curr_list_ref() + .and_then(|s| s.get_curr_ref()) + { + path = Some(s.file_path().to_path_buf()); } if let Some(path) = path { @@ -109,7 +112,7 @@ impl JoshutoRunnable for RenameFileAppend { fn execute(&self, context: &mut JoshutoContext, backend: &mut TuiBackend) -> JoshutoResult<()> { let mut file_name: Option<String> = None; - if let Some(curr_list) = context.curr_tab_ref().curr_list_ref() { + if let Some(curr_list) = context.tab_context_ref().curr_tab_ref().curr_list_ref() { file_name = curr_list.get_curr_ref().map(|s| s.file_name().to_string()); } @@ -158,7 +161,7 @@ impl JoshutoRunnable for RenameFilePrepend { fn execute(&self, context: &mut JoshutoContext, backend: &mut TuiBackend) -> JoshutoResult<()> { let mut file_name: Option<String> = None; - if let Some(curr_list) = context.curr_tab_ref().curr_list_ref() { + if let Some(curr_list) = context.tab_context_ref().curr_tab_ref().curr_list_ref() { file_name = curr_list.get_curr_ref().map(|s| s.file_name().to_string()); } |