Add reload folder key binding, fixes #146

This commit is contained in:
Jeremy Soller 2025-05-15 10:54:51 -06:00
parent 2a9b4ad068
commit 3b34ba8907
No known key found for this signature in database
GPG key ID: 670FDFB5428E05CA
5 changed files with 26 additions and 3 deletions

View file

@ -312,6 +312,7 @@ display-settings = Display settings...
file = File file = File
new-tab = New tab new-tab = New tab
new-window = New window new-window = New window
reload-folder = Reload folder
rename = Rename... rename = Rename...
close-tab = Close tab close-tab = Close tab
quit = Quit quit = Quit

View file

@ -140,6 +140,7 @@ pub enum Action {
Paste, Paste,
PermanentlyDelete, PermanentlyDelete,
Preview, Preview,
Reload,
Rename, Rename,
RestoreFromTrash, RestoreFromTrash,
SearchActivate, SearchActivate,
@ -208,6 +209,7 @@ impl Action {
Action::Paste => Message::Paste(entity_opt), Action::Paste => Message::Paste(entity_opt),
Action::PermanentlyDelete => Message::PermanentlyDelete(entity_opt), Action::PermanentlyDelete => Message::PermanentlyDelete(entity_opt),
Action::Preview => Message::Preview(entity_opt), Action::Preview => Message::Preview(entity_opt),
Action::Reload => Message::TabMessage(entity_opt, tab::Message::Reload),
Action::Rename => Message::Rename(entity_opt), Action::Rename => Message::Rename(entity_opt),
Action::RestoreFromTrash => Message::RestoreFromTrash(entity_opt), Action::RestoreFromTrash => Message::RestoreFromTrash(entity_opt),
Action::SearchActivate => Message::SearchActivate, Action::SearchActivate => Message::SearchActivate,

View file

@ -29,6 +29,7 @@ pub fn key_binds(mode: &tab::Mode) -> HashMap<KeyBind, Action> {
bind!([], Key::Named(Named::ArrowLeft), ItemLeft); bind!([], Key::Named(Named::ArrowLeft), ItemLeft);
bind!([], Key::Named(Named::ArrowRight), ItemRight); bind!([], Key::Named(Named::ArrowRight), ItemRight);
bind!([], Key::Named(Named::ArrowUp), ItemUp); bind!([], Key::Named(Named::ArrowUp), ItemUp);
bind!([], Key::Named(Named::F5), Reload);
bind!([], Key::Named(Named::Home), SelectFirst); bind!([], Key::Named(Named::Home), SelectFirst);
bind!([], Key::Named(Named::End), SelectLast); bind!([], Key::Named(Named::End), SelectLast);
bind!([Shift], Key::Named(Named::ArrowDown), ItemDown); bind!([Shift], Key::Named(Named::ArrowDown), ItemDown);

View file

@ -573,6 +573,8 @@ pub fn menu_bar<'a>(
menu::Item::Divider, menu::Item::Divider,
menu_button_optional(fl!("rename"), Action::Rename, selected > 0), menu_button_optional(fl!("rename"), Action::Rename, selected > 0),
menu::Item::Divider, menu::Item::Divider,
menu::Item::Button(fl!("reload-folder"), None, Action::Reload),
menu::Item::Divider,
menu_button_optional( menu_button_optional(
fl!("add-to-sidebar"), fl!("add-to-sidebar"),
Action::AddToSidebar, Action::AddToSidebar,

View file

@ -1403,6 +1403,7 @@ pub enum Message {
LocationUp, LocationUp,
ModifiersChanged(Modifiers), ModifiersChanged(Modifiers),
Open(Option<PathBuf>), Open(Option<PathBuf>),
Reload,
RightClick(Option<usize>), RightClick(Option<usize>),
MiddleClick(usize), MiddleClick(usize),
Scroll(Viewport), Scroll(Viewport),
@ -2483,12 +2484,12 @@ impl Tab {
// Truncate history to remove next entries // Truncate history to remove next entries
self.history.truncate(self.history_i + 1); self.history.truncate(self.history_i + 1);
// Compact consecutive search locations // Compact consecutive matching paths
{ {
let mut remove = false; let mut remove = false;
if let Some(last_location) = self.history.last() { if let Some(last_location) = self.history.last() {
if let Location::Search(last_path, ..) = last_location { if let Some(last_path) = last_location.path_opt() {
if let Location::Search(path, ..) = location { if let Some(path) = location.path_opt() {
remove = last_path == path; 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) => { Message::RightClick(click_i_opt) => {
if mod_ctrl || mod_shift { if mod_ctrl || mod_shift {
self.update(Message::Click(click_i_opt), modifiers); self.update(Message::Click(click_i_opt), modifiers);