summaryrefslogtreecommitdiffstats
path: root/src/commands
diff options
context:
space:
mode:
Diffstat (limited to 'src/commands')
-rw-r--r--src/commands/open_file.rs13
-rw-r--r--src/commands/parent_cursor_move.rs10
2 files changed, 14 insertions, 9 deletions
diff --git a/src/commands/open_file.rs b/src/commands/open_file.rs
index c680cb7..c93f721 100644
--- a/src/commands/open_file.rs
+++ b/src/commands/open_file.rs
@@ -18,12 +18,15 @@ use crate::MIMETYPE_T;
fn _get_options<'a>(path: &path::Path) -> Vec<&'a ProgramEntry> {
let mut options: Vec<&ProgramEntry> = Vec::new();
- if let Some(file_ext) = path.extension().and_then(|ext| ext.to_str()) {
- if let Some(entries) = MIMETYPE_T.app_list_for_ext(file_ext) {
- options.extend(entries);
- return options;
- }
+ if let Some(entries) = path
+ .extension()
+ .and_then(|ext| ext.to_str())
+ .and_then(|file_ext| MIMETYPE_T.app_list_for_ext(file_ext))
+ {
+ options.extend(entries);
+ return options;
}
+
if let Ok(file_mimetype) = get_mimetype(path) {
if let Some(entry) = MIMETYPE_T.app_list_for_mimetype(file_mimetype.get_type()) {
match entry.subtypes().get(file_mimetype.get_subtype()) {
diff --git a/src/commands/parent_cursor_move.rs b/src/commands/parent_cursor_move.rs
index b6c26fb..b19ebe3 100644
--- a/src/commands/parent_cursor_move.rs
+++ b/src/commands/parent_cursor_move.rs
@@ -46,10 +46,12 @@ pub fn parent_up(context: &mut AppContext, u: usize) -> JoshutoResult {
}
pub fn parent_down(context: &mut AppContext, u: usize) -> JoshutoResult {
- let movement = match context.tab_context_ref().curr_tab_ref().parent_list_ref() {
- Some(list) => list.get_index().map(|idx| idx + u),
- None => None,
- };
+ let movement = context
+ .tab_context_ref()
+ .curr_tab_ref()
+ .parent_list_ref()
+ .and_then(|list| list.get_index().map(|idx| idx + u));
+
if let Some(s) = movement {
parent_cursor_move(context, s)?;
}