summaryrefslogtreecommitdiffstats
path: root/src/commands/delete_files.rs
diff options
context:
space:
mode:
authorJiayi Zhao <jeff.no.zhao@gmail.com>2019-06-05 16:41:26 -0400
committerJiayi Zhao <jeff.no.zhao@gmail.com>2019-06-05 16:41:31 -0400
commit89dadc7c604cb8367b90c4cc0f097d2fabc93ac6 (patch)
tree72725729821171385d36cc60579366a3b2e91c01 /src/commands/delete_files.rs
parent530973aea3fa46c469541bc291513a75e3aacd3e (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/delete_files.rs')
-rw-r--r--src/commands/delete_files.rs31
1 files changed, 18 insertions, 13 deletions
diff --git a/src/commands/delete_files.rs b/src/commands/delete_files.rs
index f971ab6..4d7924b 100644
--- a/src/commands/delete_files.rs
+++ b/src/commands/delete_files.rs
@@ -44,19 +44,24 @@ impl DeleteFiles {
let curr_tab = &mut context.tabs[context.curr_tab_index];
let mut ch = ncurses::getch();
if ch == 'y' as i32 || ch == KEYMAP_T.enter {
- if let Some(paths) = curr_tab.curr_list.get_selected_paths() {
- if paths.len() > 1 {
- ui::wprint_msg(&view.bot_win, "Are you sure? (y/N)");
- ncurses::doupdate();
- ch = ncurses::getch();
- } else {
- ch = 'y' as i32;
- }
- if ch == 'y' as i32 {
- Self::remove_files(&paths)?;
- ui::wprint_msg(&view.bot_win, "Deleted files");
- ReloadDirList::reload(context.curr_tab_index, context)?;
- }
+ let paths = curr_tab.curr_list.get_selected_paths();
+ if paths.is_empty() {
+ return Err(std::io::Error::new(
+ std::io::ErrorKind::Other,
+ "no files selected",
+ ));
+ }
+ if paths.len() > 1 {
+ ui::wprint_msg(&view.bot_win, "Are you sure? (y/N)");
+ ncurses::doupdate();
+ ch = ncurses::getch();
+ } else {
+ ch = 'y' as i32;
+ }
+ if ch == 'y' as i32 {
+ Self::remove_files(&paths)?;
+ ui::wprint_msg(&view.bot_win, "Deleted files");
+ ReloadDirList::reload(context.curr_tab_index, context)?;
}
}
Ok(())