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/selection.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/selection.rs')
-rw-r--r-- | src/commands/selection.rs | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/src/commands/selection.rs b/src/commands/selection.rs index dccb114..aced34f 100644 --- a/src/commands/selection.rs +++ b/src/commands/selection.rs @@ -35,35 +35,36 @@ impl std::fmt::Display for SelectFiles { impl JoshutoRunnable for SelectFiles { fn execute(&self, context: &mut JoshutoContext, backend: &mut TuiBackend) -> JoshutoResult<()> { - let curr_tab = &mut context.tabs[context.curr_tab_index]; if self.toggle { if !self.all { - let curr_list = curr_tab.curr_list_mut(); - if let Some(curr_list) = curr_list { - if let Some(s) = curr_list.get_curr_mut() { - s.set_selected(!s.is_selected()); - CursorMoveDown::new(1).execute(context, backend)?; - } + if let Some(s) = context + .tab_context_mut() + .curr_tab_mut() + .curr_list_mut() + .and_then(|s| s.get_curr_mut()) + { + s.set_selected(!s.is_selected()); + CursorMoveDown::new(1).execute(context, backend)?; } } else { - let curr_list = curr_tab.curr_list_mut(); - if let Some(curr_list) = curr_list { + if let Some(curr_list) = context.tab_context_mut().curr_tab_mut().curr_list_mut() { for curr in &mut curr_list.contents { curr.set_selected(!curr.is_selected()); } } } } else if !self.all { - let curr_list = curr_tab.curr_list_mut(); - if let Some(curr_list) = curr_list { - if let Some(s) = curr_list.get_curr_mut() { - s.set_selected(!s.is_selected()); - CursorMoveDown::new(1).execute(context, backend)?; - } + if let Some(s) = context + .tab_context_mut() + .curr_tab_mut() + .curr_list_mut() + .and_then(|s| s.get_curr_mut()) + { + s.set_selected(!s.is_selected()); + CursorMoveDown::new(1).execute(context, backend)?; } } else { - let curr_list = curr_tab.curr_list_mut(); - if let Some(curr_list) = curr_list { + if let Some(curr_list) = context.tab_context_mut().curr_tab_mut().curr_list_mut() { for curr in &mut curr_list.contents { curr.set_selected(true); } |