Scroll to focused item on tab rescan, fixes #1281
This commit is contained in:
parent
eaa756182a
commit
5edeea69f9
2 changed files with 21 additions and 2 deletions
15
src/app.rs
15
src/app.rs
|
|
@ -4153,10 +4153,19 @@ impl Application for App {
|
|||
tab.sort_name = sort.0;
|
||||
tab.sort_direction = sort.1;
|
||||
|
||||
let mut tasks = Vec::with_capacity(2);
|
||||
|
||||
if let Some(selection_paths) = selection_paths {
|
||||
tab.select_paths(selection_paths);
|
||||
|
||||
// Ensure selected path is scrolled to after redraw
|
||||
tasks.push(Task::done(cosmic::action::app(Message::TabMessage(
|
||||
Some(entity),
|
||||
tab::Message::ScrollToFocused,
|
||||
))));
|
||||
}
|
||||
return clipboard::read_data::<ClipboardPaste>().map(|p| {
|
||||
|
||||
tasks.push(clipboard::read_data::<ClipboardPaste>().map(|p| {
|
||||
cosmic::action::app(Message::CutPaths(match p {
|
||||
Some(s) => match s.kind {
|
||||
ClipboardKind::Copy => Vec::new(),
|
||||
|
|
@ -4164,7 +4173,9 @@ impl Application for App {
|
|||
},
|
||||
None => Vec::new(),
|
||||
}))
|
||||
});
|
||||
}));
|
||||
|
||||
return Task::batch(tasks);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1664,6 +1664,7 @@ pub enum Message {
|
|||
Resize(Rectangle),
|
||||
Scroll(Viewport),
|
||||
ScrollTab(f32),
|
||||
ScrollToFocused,
|
||||
SearchContext(Location, SearchContextWrapper),
|
||||
SearchReady(bool),
|
||||
SelectAll,
|
||||
|
|
@ -3880,6 +3881,13 @@ impl Tab {
|
|||
.into(),
|
||||
));
|
||||
}
|
||||
Message::ScrollToFocused => {
|
||||
if let Some(offset) = self.select_focus_scroll() {
|
||||
commands.push(Command::Iced(
|
||||
scrollable::scroll_to(self.scrollable_id.clone(), offset).into(),
|
||||
));
|
||||
}
|
||||
}
|
||||
Message::SearchContext(location, context) => {
|
||||
if location == self.location {
|
||||
self.search_context = context.0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue