Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): state order and handling of new trees #156

Merged
merged 1 commit into from
Jul 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions core/src/widget/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

thread_local! {
/// A map of named widget states.
pub static NAMED: std::cell::RefCell<HashMap<Cow<'static, str>, (State, Vec<(usize, Tree)>)>> = std::cell::RefCell::new(HashMap::new());

Check warning on line 12 in core/src/widget/tree.rs

View workflow job for this annotation

GitHub Actions / all

very complex type used. Consider factoring parts into `type` definitions

Check warning on line 12 in core/src/widget/tree.rs

View workflow job for this annotation

GitHub Actions / all

very complex type used. Consider factoring parts into `type` definitions
}

/// A persistent state widget tree.
Expand Down Expand Up @@ -61,7 +61,7 @@
/// Takes all named widgets from the tree.
pub fn take_all_named(
&mut self,
) -> HashMap<Cow<'static, str>, (State, Vec<(usize, Tree)>)> {

Check warning on line 64 in core/src/widget/tree.rs

View workflow job for this annotation

GitHub Actions / all

very complex type used. Consider factoring parts into `type` definitions

Check warning on line 64 in core/src/widget/tree.rs

View workflow job for this annotation

GitHub Actions / all

very complex type used. Consider factoring parts into `type` definitions
let mut named = HashMap::new();
struct Visit {
parent: Cow<'static, str>,
Expand All @@ -76,7 +76,7 @@
let state = mem::replace(&mut tree.state, State::None);
let children_count = tree.children.len();
let children =
tree.children.iter_mut().rev().enumerate().map(|(i, c)| {
tree.children.iter_mut().enumerate().rev().map(|(i, c)| {
if matches!(c.id, Some(Id(Internal::Custom(_, _)))) {
(c, None)
} else {
Expand Down Expand Up @@ -350,7 +350,11 @@
}

for (new_tree, i) in new_trees {
self.children.insert(i, new_tree);
if self.children.len() > i {
self.children[i] = new_tree;
} else {
self.children.push(new_tree);
}
}
}
}
Expand Down
Loading