diff options
author | Jiayi Zhao <jeff.no.zhao@gmail.com> | 2019-06-05 16:41:26 -0400 |
---|---|---|
committer | Jiayi Zhao <jeff.no.zhao@gmail.com> | 2019-06-05 16:41:31 -0400 |
commit | 89dadc7c604cb8367b90c4cc0f097d2fabc93ac6 (patch) | |
tree | 72725729821171385d36cc60579366a3b2e91c01 /src/commands/open_file.rs | |
parent | 530973aea3fa46c469541bc291513a75e3aacd3e (diff) |
get_selected_paths now returns just a vec rather an option
- fix not being able to select the current entry
Diffstat (limited to 'src/commands/open_file.rs')
-rw-r--r-- | src/commands/open_file.rs | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/commands/open_file.rs b/src/commands/open_file.rs index 34f823a..bdc8e44 100644 --- a/src/commands/open_file.rs +++ b/src/commands/open_file.rs @@ -58,14 +58,13 @@ impl OpenFile { curr_tab.refresh(view, &context.config_t); } else { let curr_tab = &context.tabs[context.curr_tab_index]; - let paths: Option<Vec<&PathBuf>> = curr_tab.curr_list.get_selected_paths(); + let paths = curr_tab.curr_list.get_selected_paths(); - if let Some(paths) = paths { - Self::open_file(&paths); - } else { + if paths.is_empty() { let err = std::io::Error::new(std::io::ErrorKind::NotFound, "No files selected"); return Err(err); } + Self::open_file(&paths); let curr_tab = &mut context.tabs[context.curr_tab_index]; if curr_tab.curr_list.need_update() { curr_tab @@ -214,9 +213,8 @@ impl std::fmt::Display for OpenFileWith { impl JoshutoRunnable for OpenFileWith { fn execute(&self, context: &mut JoshutoContext, _: &JoshutoView) -> Result<(), JoshutoError> { let curr_list = &context.tabs[context.curr_tab_index].curr_list; - if let Some(paths) = curr_list.get_selected_paths() { - Self::open_with(&paths); - } + let paths = curr_list.get_selected_paths(); + Self::open_with(&paths); Ok(()) } } |