diff --git a/i18n/en/cosmic_files.ftl b/i18n/en/cosmic_files.ftl index 881741f..78dd002 100644 --- a/i18n/en/cosmic_files.ftl +++ b/i18n/en/cosmic_files.ftl @@ -312,6 +312,7 @@ display-settings = Display settings... file = File new-tab = New tab new-window = New window +reload-folder = Reload folder rename = Rename... close-tab = Close tab quit = Quit diff --git a/src/app.rs b/src/app.rs index 1ab1791..c8fcaeb 100644 --- a/src/app.rs +++ b/src/app.rs @@ -140,6 +140,7 @@ pub enum Action { Paste, PermanentlyDelete, Preview, + Reload, Rename, RestoreFromTrash, SearchActivate, @@ -208,6 +209,7 @@ impl Action { Action::Paste => Message::Paste(entity_opt), Action::PermanentlyDelete => Message::PermanentlyDelete(entity_opt), Action::Preview => Message::Preview(entity_opt), + Action::Reload => Message::TabMessage(entity_opt, tab::Message::Reload), Action::Rename => Message::Rename(entity_opt), Action::RestoreFromTrash => Message::RestoreFromTrash(entity_opt), Action::SearchActivate => Message::SearchActivate, diff --git a/src/key_bind.rs b/src/key_bind.rs index e0b528e..3e7b4c6 100644 --- a/src/key_bind.rs +++ b/src/key_bind.rs @@ -29,6 +29,7 @@ pub fn key_binds(mode: &tab::Mode) -> HashMap { bind!([], Key::Named(Named::ArrowLeft), ItemLeft); bind!([], Key::Named(Named::ArrowRight), ItemRight); bind!([], Key::Named(Named::ArrowUp), ItemUp); + bind!([], Key::Named(Named::F5), Reload); bind!([], Key::Named(Named::Home), SelectFirst); bind!([], Key::Named(Named::End), SelectLast); bind!([Shift], Key::Named(Named::ArrowDown), ItemDown); diff --git a/src/menu.rs b/src/menu.rs index d148069..56541a9 100644 --- a/src/menu.rs +++ b/src/menu.rs @@ -573,6 +573,8 @@ pub fn menu_bar<'a>( menu::Item::Divider, menu_button_optional(fl!("rename"), Action::Rename, selected > 0), menu::Item::Divider, + menu::Item::Button(fl!("reload-folder"), None, Action::Reload), + menu::Item::Divider, menu_button_optional( fl!("add-to-sidebar"), Action::AddToSidebar, diff --git a/src/tab.rs b/src/tab.rs index cccd5b0..fcd2a38 100644 --- a/src/tab.rs +++ b/src/tab.rs @@ -1403,6 +1403,7 @@ pub enum Message { LocationUp, ModifiersChanged(Modifiers), Open(Option), + Reload, RightClick(Option), MiddleClick(usize), Scroll(Viewport), @@ -2483,12 +2484,12 @@ impl Tab { // Truncate history to remove next entries self.history.truncate(self.history_i + 1); - // Compact consecutive search locations + // Compact consecutive matching paths { let mut remove = false; if let Some(last_location) = self.history.last() { - if let Location::Search(last_path, ..) = last_location { - if let Location::Search(path, ..) = location { + if let Some(last_path) = last_location.path_opt() { + if let Some(path) = location.path_opt() { remove = last_path == path; } } @@ -3215,6 +3216,22 @@ impl Tab { } } } + Message::Reload => { + let mut selected_paths = Vec::new(); + //TODO: support keeping selected locations without paths + for location in self.selected_locations() { + if let Some(path) = location.path_opt() { + selected_paths.push(path.to_path_buf()); + } + } + let location = self.location.clone(); + self.change_location(&location, None); + commands.push(Command::ChangeLocation( + self.title(), + location, + Some(selected_paths), + )); + } Message::RightClick(click_i_opt) => { if mod_ctrl || mod_shift { self.update(Message::Click(click_i_opt), modifiers);