Scroll to the top after changing location, fixes #448

This commit is contained in:
Jeremy Soller 2024-09-25 15:32:54 -06:00
parent 6891564533
commit 5a3c63df17
No known key found for this signature in database
GPG key ID: D02FD439211AF56F

View file

@ -1704,10 +1704,12 @@ impl Tab {
pub fn change_location(&mut self, location: &Location, history_i_opt: Option<usize>) {
self.location = location.clone();
self.items_opt = None;
self.select_focus = None;
self.context_menu = None;
self.edit_location = None;
self.items_opt = None;
//TODO: remember scroll by location?
self.scroll_opt = None;
self.select_focus = None;
if let Some(history_i) = history_i_opt {
// Navigating in history
self.history_i = history_i;
@ -2493,6 +2495,16 @@ impl Tab {
}
}
// Scroll to top if needed
if self.scroll_opt.is_none() {
let offset = AbsoluteOffset { x: 0.0, y: 0.0 };
self.scroll_opt = Some(offset);
commands.push(Command::Iced(scrollable::scroll_to(
self.scrollable_id.clone(),
offset,
)));
}
// Change directory if requested
if let Some(location) = cd {
if matches!(self.mode, Mode::Desktop) {
@ -4009,7 +4021,7 @@ impl Tab {
//TODO: configurable thumbnail size?
let thumbnail_size = (ICON_SIZE_GRID * ICON_SCALE_MAX) as u32;
let thumbnail = ItemThumbnail::new(&path, mime, thumbnail_size);
log::info!("thumbnailed {:?} in {:?}", path, start.elapsed());
log::debug!("thumbnailed {:?} in {:?}", path, start.elapsed());
(path, thumbnail)
})
.await