diff options
author | qkzk <qu3nt1n@gmail.com> | 2023-10-25 18:26:52 +0200 |
---|---|---|
committer | qkzk <qu3nt1n@gmail.com> | 2023-10-25 18:26:52 +0200 |
commit | 1c3cc930f3db8f483a739766317958bdf47e3e29 (patch) | |
tree | ce622cdddf917ad355c4df9b848140e4f15ebbfc | |
parent | 055a45599e8340e5893c8c06835990151ac934e4 (diff) |
Flag the selected file if no file is flagged before entering delete mode or trashing a file.
-rw-r--r-- | development.md | 2 | ||||
-rw-r--r-- | src/event_exec.rs | 13 |
2 files changed, 11 insertions, 4 deletions
diff --git a/development.md b/development.md index 6bb02f1..e158cc4 100644 --- a/development.md +++ b/development.md @@ -587,6 +587,8 @@ New view: Tree ! Toggle with 't', fold with 'z'. Navigate normally. - [x] FIX: group & owner metadata alignement in tree mode - [x] Tree mode Copy / Move / New should copy in selected directory not root of tree - [x] Allow scrolling in preview pdf. Required a lot of change in Preview::ueberzug. Update thumbnail when required. +- [x] Flag the selected file if no file is flagged before entering delete mode or trashing a file. +- [ ] fuzzy finder should do nothing if escape (quit?) is inputed - [ ] document filepicking (from my config etc.). - [ ] avoid multiple refreshs if we edit files ourself diff --git a/src/event_exec.rs b/src/event_exec.rs index 6fce1a5..8f7bc38 100644 --- a/src/event_exec.rs +++ b/src/event_exec.rs @@ -62,7 +62,7 @@ impl EventAction { .for_each(|file| { status.flagged.push(file.path.clone()); }); - status.reset_tabs_view() + Ok(()) } /// Reverse every flag in _current_ directory. Flagged files in other @@ -73,7 +73,7 @@ impl EventAction { .content .iter() .for_each(|file| status.flagged.toggle(&file.path)); - status.reset_tabs_view() + Ok(()) } /// Toggle a single flag and move down one row. @@ -259,10 +259,10 @@ impl EventAction { /// Enter the delete mode. /// A confirmation is then asked before deleting all the flagged files. - /// Does nothing is no file is flagged. + /// If no file is flagged, flag the selected one before entering the mode. pub fn delete_file(status: &mut Status) -> Result<()> { if status.flagged.is_empty() { - return Ok(()); + Self::toggle_flag(status)?; } status .selected() @@ -887,12 +887,17 @@ impl EventAction { status.select_tab(0)?; Ok(()) } + /// Move flagged files to the trash directory. + /// If no file is flagged, flag the selected file. /// More information in the trash crate itself. /// If the file is mounted on the $topdir of the trash (aka the $HOME mount point), /// it is moved there. /// Else, nothing is done. pub fn trash_move_file(status: &mut Status) -> Result<()> { + if status.flagged.is_empty() { + Self::toggle_flag(status)?; + } let trash_mount_point = opt_mount_point(disk_used_by_path( status.system_info.disks(), &std::path::PathBuf::from(&status.trash.trash_folder_files), |