mirror of
https://github.com/zed-industries/zed.git
synced 2026-06-02 07:04:33 +00:00
Avoid pushing empty leaves into the tree
This commit is contained in:
parent
198be71b6c
commit
cbc5dc04ef
1 changed files with 35 additions and 17 deletions
|
|
@ -425,26 +425,44 @@ impl<T: Item> Sequence<T> {
|
|||
}
|
||||
ChildTree::Unloaded { saved_id } => {
|
||||
if self.0.is_leaf() {
|
||||
let mut summary = self.0.summary().clone();
|
||||
Summary::add_summary(&mut summary, &other_summary, cx);
|
||||
if self.0.items().is_empty() {
|
||||
let mut child_summaries = ArrayVec::new();
|
||||
child_summaries.push(other_summary.clone());
|
||||
|
||||
let mut child_summaries = ArrayVec::new();
|
||||
child_summaries.push(self.0.summary().clone());
|
||||
child_summaries.push(other_summary);
|
||||
let mut child_trees = ArrayVec::new();
|
||||
child_trees.push(ChildTree::Unloaded {
|
||||
saved_id: saved_id.clone(),
|
||||
});
|
||||
|
||||
let mut child_trees = ArrayVec::new();
|
||||
child_trees.push(ChildTree::Loaded { tree: self.clone() });
|
||||
child_trees.push(ChildTree::Unloaded {
|
||||
saved_id: saved_id.clone(),
|
||||
});
|
||||
*self = Self(Arc::new(Node::Internal {
|
||||
saved_id: Default::default(),
|
||||
height: 1,
|
||||
summary: other_summary,
|
||||
child_summaries,
|
||||
child_trees,
|
||||
}));
|
||||
} else {
|
||||
let mut summary = self.0.summary().clone();
|
||||
Summary::add_summary(&mut summary, &other_summary, cx);
|
||||
|
||||
*self = Self(Arc::new(Node::Internal {
|
||||
saved_id: Default::default(),
|
||||
height: self.0.height() + 1,
|
||||
summary,
|
||||
child_summaries,
|
||||
child_trees,
|
||||
}));
|
||||
let mut child_summaries = ArrayVec::new();
|
||||
child_summaries.push(self.0.summary().clone());
|
||||
child_summaries.push(other_summary);
|
||||
|
||||
let mut child_trees = ArrayVec::new();
|
||||
child_trees.push(ChildTree::Loaded { tree: self.clone() });
|
||||
child_trees.push(ChildTree::Unloaded {
|
||||
saved_id: saved_id.clone(),
|
||||
});
|
||||
|
||||
*self = Self(Arc::new(Node::Internal {
|
||||
saved_id: Default::default(),
|
||||
height: 1,
|
||||
summary,
|
||||
child_summaries,
|
||||
child_trees,
|
||||
}));
|
||||
}
|
||||
} else if let Some(split_tree) =
|
||||
self.push_tree_recursive(other_child, other_summary, cx)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue