diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b0dc92..183b849 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,9 @@ Released on 13/12/2020 - General performance and code improvements - Improved symlinks management - Possibility to abort file transfers +- Enhancements: + - File explorer: + - when file index is at the end of the list, moving down will set the current index to the first element and viceversa. - Keybindings: - `E`: Delete file (Same as `DEL`); added because some keyboards don't have `DEL` (hey, that's my MacBook Air's keyboard!) - `Ctrl+C`: Abort transfer process diff --git a/src/ui/activities/filetransfer_activity/input.rs b/src/ui/activities/filetransfer_activity/input.rs index 9559a68..bccdeee 100644 --- a/src/ui/activities/filetransfer_activity/input.rs +++ b/src/ui/activities/filetransfer_activity/input.rs @@ -29,9 +29,8 @@ use std::path::PathBuf; use tui::style::Color; impl FileTransferActivity { - /// ### read_input_event - /// + /// /// Read one event. /// Returns whether at least one event has been handled pub(super) fn read_input_event(&mut self) -> bool { @@ -42,10 +41,12 @@ impl FileTransferActivity { self.handle_input_event(&event); // Return true true - } else { // No event + } else { + // No event false } - } else { // Error + } else { + // Error false } } @@ -100,15 +101,18 @@ impl FileTransferActivity { KeyCode::Tab => self.switch_input_field(), // switch tab KeyCode::Right => self.tab = FileExplorerTab::Remote, // switch to right tab KeyCode::Up => { - // Move index up - if self.local.index > 0 { - self.local.index -= 1; - } + // Move index up; or move to the last element if 0 + self.local.index = match self.local.index { + 0 => self.local.files.len() - 1, + _ => self.local.index - 1, + }; } KeyCode::Down => { // Move index down if self.local.index + 1 < self.local.files.len() { self.local.index += 1; + } else { + self.local.index = 0; // Move at the beginning of the list } } KeyCode::PageUp => { @@ -289,15 +293,18 @@ impl FileTransferActivity { KeyCode::Tab => self.switch_input_field(), // switch tab KeyCode::Left => self.tab = FileExplorerTab::Local, // switch to local tab KeyCode::Up => { - // Move index up - if self.remote.index > 0 { - self.remote.index -= 1; - } + // Move index up; or move to the last element if 0 + self.remote.index = match self.remote.index { + 0 => self.remote.files.len() - 1, + _ => self.remote.index - 1, + }; } KeyCode::Down => { // Move index down if self.remote.index + 1 < self.remote.files.len() { self.remote.index += 1; + } else { + self.remote.index = 0; // Move at the beginning of the list } } KeyCode::PageUp => {