summaryrefslogtreecommitdiffstats
path: root/src/commands/open_file.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/commands/open_file.rs')
-rw-r--r--src/commands/open_file.rs21
1 files changed, 12 insertions, 9 deletions
diff --git a/src/commands/open_file.rs b/src/commands/open_file.rs
index 41f9a8b..71946d3 100644
--- a/src/commands/open_file.rs
+++ b/src/commands/open_file.rs
@@ -35,11 +35,12 @@ pub fn open(context: &mut AppContext, backend: &mut TuiBackend) -> JoshutoResult
change_directory::cd(path.as_path(), context)?;
LoadChild::load_child(context)?;
} else {
- let paths: Vec<path::PathBuf> =
- match context.tab_context_ref().curr_tab_ref().curr_list_ref() {
- Some(a) => a.get_selected_paths(),
- None => vec![],
- };
+ let paths = context
+ .tab_context_ref()
+ .curr_tab_ref()
+ .curr_list_ref()
+ .map_or(vec![], |s| s.get_selected_paths());
+
if paths.is_empty() {
return Err(JoshutoError::new(
JoshutoErrorKind::Io(io::ErrorKind::NotFound),
@@ -133,10 +134,12 @@ where
}
pub fn open_with(context: &mut AppContext, backend: &mut TuiBackend) -> JoshutoResult<()> {
- let paths: Vec<path::PathBuf> = match context.tab_context_ref().curr_tab_ref().curr_list_ref() {
- Some(a) => a.get_selected_paths(),
- None => vec![],
- };
+ let paths = context
+ .tab_context_ref()
+ .curr_tab_ref()
+ .curr_list_ref()
+ .map_or(vec![], |s| s.get_selected_paths());
+
if paths.is_empty() {
return Err(JoshutoError::new(
JoshutoErrorKind::Io(io::ErrorKind::NotFound),