mirror of
https://github.com/zed-industries/zed.git
synced 2024-12-26 23:22:41 +03:00
Rename SumTree::push_tree to ::append
This commit is contained in:
parent
05d69c804c
commit
8c298a9da5
@ -243,7 +243,7 @@ impl BlockMap {
|
||||
// Preserve any old transforms that precede this edit.
|
||||
let old_start = WrapRow(edit.old.start);
|
||||
let new_start = WrapRow(edit.new.start);
|
||||
new_transforms.push_tree(cursor.slice(&old_start, Bias::Left, &()), &());
|
||||
new_transforms.append(cursor.slice(&old_start, Bias::Left, &()), &());
|
||||
if let Some(transform) = cursor.item() {
|
||||
if transform.is_isomorphic() && old_start == cursor.end(&()) {
|
||||
new_transforms.push(transform.clone(), &());
|
||||
@ -425,7 +425,7 @@ impl BlockMap {
|
||||
push_isomorphic(&mut new_transforms, extent_after_edit);
|
||||
}
|
||||
|
||||
new_transforms.push_tree(cursor.suffix(&()), &());
|
||||
new_transforms.append(cursor.suffix(&()), &());
|
||||
debug_assert_eq!(
|
||||
new_transforms.summary().input_rows,
|
||||
wrap_snapshot.max_point().row() + 1
|
||||
|
@ -115,10 +115,10 @@ impl<'a> FoldMapWriter<'a> {
|
||||
let mut new_tree = SumTree::new();
|
||||
let mut cursor = self.0.folds.cursor::<Fold>();
|
||||
for fold in folds {
|
||||
new_tree.push_tree(cursor.slice(&fold, Bias::Right, &buffer), &buffer);
|
||||
new_tree.append(cursor.slice(&fold, Bias::Right, &buffer), &buffer);
|
||||
new_tree.push(fold, &buffer);
|
||||
}
|
||||
new_tree.push_tree(cursor.suffix(&buffer), &buffer);
|
||||
new_tree.append(cursor.suffix(&buffer), &buffer);
|
||||
new_tree
|
||||
};
|
||||
|
||||
@ -165,10 +165,10 @@ impl<'a> FoldMapWriter<'a> {
|
||||
let mut cursor = self.0.folds.cursor::<usize>();
|
||||
let mut folds = SumTree::new();
|
||||
for fold_ix in fold_ixs_to_delete {
|
||||
folds.push_tree(cursor.slice(&fold_ix, Bias::Right, &buffer), &buffer);
|
||||
folds.append(cursor.slice(&fold_ix, Bias::Right, &buffer), &buffer);
|
||||
cursor.next(&buffer);
|
||||
}
|
||||
folds.push_tree(cursor.suffix(&buffer), &buffer);
|
||||
folds.append(cursor.suffix(&buffer), &buffer);
|
||||
folds
|
||||
};
|
||||
|
||||
@ -302,7 +302,7 @@ impl FoldMap {
|
||||
cursor.seek(&0, Bias::Right, &());
|
||||
|
||||
while let Some(mut edit) = buffer_edits_iter.next() {
|
||||
new_transforms.push_tree(cursor.slice(&edit.old.start, Bias::Left, &()), &());
|
||||
new_transforms.append(cursor.slice(&edit.old.start, Bias::Left, &()), &());
|
||||
edit.new.start -= edit.old.start - cursor.start();
|
||||
edit.old.start = *cursor.start();
|
||||
|
||||
@ -412,7 +412,7 @@ impl FoldMap {
|
||||
}
|
||||
}
|
||||
|
||||
new_transforms.push_tree(cursor.suffix(&()), &());
|
||||
new_transforms.append(cursor.suffix(&()), &());
|
||||
if new_transforms.is_empty() {
|
||||
let text_summary = new_buffer.text_summary();
|
||||
new_transforms.push(
|
||||
|
@ -353,7 +353,7 @@ impl WrapSnapshot {
|
||||
}
|
||||
|
||||
old_cursor.next(&());
|
||||
new_transforms.push_tree(
|
||||
new_transforms.append(
|
||||
old_cursor.slice(&next_edit.old.start, Bias::Right, &()),
|
||||
&(),
|
||||
);
|
||||
@ -366,7 +366,7 @@ impl WrapSnapshot {
|
||||
new_transforms.push_or_extend(Transform::isomorphic(summary));
|
||||
}
|
||||
old_cursor.next(&());
|
||||
new_transforms.push_tree(old_cursor.suffix(&()), &());
|
||||
new_transforms.append(old_cursor.suffix(&()), &());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -500,7 +500,7 @@ impl WrapSnapshot {
|
||||
new_transforms.push_or_extend(Transform::isomorphic(summary));
|
||||
}
|
||||
old_cursor.next(&());
|
||||
new_transforms.push_tree(
|
||||
new_transforms.append(
|
||||
old_cursor.slice(
|
||||
&TabPoint::new(next_edit.old_rows.start, 0),
|
||||
Bias::Right,
|
||||
@ -517,7 +517,7 @@ impl WrapSnapshot {
|
||||
new_transforms.push_or_extend(Transform::isomorphic(summary));
|
||||
}
|
||||
old_cursor.next(&());
|
||||
new_transforms.push_tree(old_cursor.suffix(&()), &());
|
||||
new_transforms.append(old_cursor.suffix(&()), &());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1010,7 +1010,7 @@ impl MultiBuffer {
|
||||
|
||||
let suffix = cursor.suffix(&());
|
||||
let changed_trailing_excerpt = suffix.is_empty();
|
||||
new_excerpts.push_tree(suffix, &());
|
||||
new_excerpts.append(suffix, &());
|
||||
drop(cursor);
|
||||
snapshot.excerpts = new_excerpts;
|
||||
snapshot.excerpt_ids = new_excerpt_ids;
|
||||
@ -1193,7 +1193,7 @@ impl MultiBuffer {
|
||||
while let Some(excerpt_id) = excerpt_ids.next() {
|
||||
// Seek to the next excerpt to remove, preserving any preceding excerpts.
|
||||
let locator = snapshot.excerpt_locator_for_id(excerpt_id);
|
||||
new_excerpts.push_tree(cursor.slice(&Some(locator), Bias::Left, &()), &());
|
||||
new_excerpts.append(cursor.slice(&Some(locator), Bias::Left, &()), &());
|
||||
|
||||
if let Some(mut excerpt) = cursor.item() {
|
||||
if excerpt.id != excerpt_id {
|
||||
@ -1245,7 +1245,7 @@ impl MultiBuffer {
|
||||
}
|
||||
let suffix = cursor.suffix(&());
|
||||
let changed_trailing_excerpt = suffix.is_empty();
|
||||
new_excerpts.push_tree(suffix, &());
|
||||
new_excerpts.append(suffix, &());
|
||||
drop(cursor);
|
||||
snapshot.excerpts = new_excerpts;
|
||||
|
||||
@ -1509,7 +1509,7 @@ impl MultiBuffer {
|
||||
let mut cursor = snapshot.excerpts.cursor::<(Option<&Locator>, usize)>();
|
||||
|
||||
for (locator, buffer, buffer_edited) in excerpts_to_edit {
|
||||
new_excerpts.push_tree(cursor.slice(&Some(locator), Bias::Left, &()), &());
|
||||
new_excerpts.append(cursor.slice(&Some(locator), Bias::Left, &()), &());
|
||||
let old_excerpt = cursor.item().unwrap();
|
||||
let buffer = buffer.read(cx);
|
||||
let buffer_id = buffer.remote_id();
|
||||
@ -1549,7 +1549,7 @@ impl MultiBuffer {
|
||||
new_excerpts.push(new_excerpt, &());
|
||||
cursor.next(&());
|
||||
}
|
||||
new_excerpts.push_tree(cursor.suffix(&()), &());
|
||||
new_excerpts.append(cursor.suffix(&()), &());
|
||||
|
||||
drop(cursor);
|
||||
snapshot.excerpts = new_excerpts;
|
||||
|
@ -211,7 +211,7 @@ impl<V: View> Element<V> for List<V> {
|
||||
let mut cursor = old_items.cursor::<Count>();
|
||||
|
||||
if state.rendered_range.start < new_rendered_range.start {
|
||||
new_items.push_tree(
|
||||
new_items.append(
|
||||
cursor.slice(&Count(state.rendered_range.start), Bias::Right, &()),
|
||||
&(),
|
||||
);
|
||||
@ -221,7 +221,7 @@ impl<V: View> Element<V> for List<V> {
|
||||
cursor.next(&());
|
||||
}
|
||||
}
|
||||
new_items.push_tree(
|
||||
new_items.append(
|
||||
cursor.slice(&Count(new_rendered_range.start), Bias::Right, &()),
|
||||
&(),
|
||||
);
|
||||
@ -230,7 +230,7 @@ impl<V: View> Element<V> for List<V> {
|
||||
cursor.seek(&Count(new_rendered_range.end), Bias::Right, &());
|
||||
|
||||
if new_rendered_range.end < state.rendered_range.start {
|
||||
new_items.push_tree(
|
||||
new_items.append(
|
||||
cursor.slice(&Count(state.rendered_range.start), Bias::Right, &()),
|
||||
&(),
|
||||
);
|
||||
@ -240,7 +240,7 @@ impl<V: View> Element<V> for List<V> {
|
||||
cursor.next(&());
|
||||
}
|
||||
|
||||
new_items.push_tree(cursor.suffix(&()), &());
|
||||
new_items.append(cursor.suffix(&()), &());
|
||||
|
||||
state.items = new_items;
|
||||
state.rendered_range = new_rendered_range;
|
||||
@ -413,7 +413,7 @@ impl<V: View> ListState<V> {
|
||||
old_heights.seek_forward(&Count(old_range.end), Bias::Right, &());
|
||||
|
||||
new_heights.extend((0..count).map(|_| ListItem::Unrendered), &());
|
||||
new_heights.push_tree(old_heights.suffix(&()), &());
|
||||
new_heights.append(old_heights.suffix(&()), &());
|
||||
drop(old_heights);
|
||||
state.items = new_heights;
|
||||
}
|
||||
|
@ -288,7 +288,7 @@ impl SyntaxSnapshot {
|
||||
};
|
||||
if target.cmp(&cursor.start(), text).is_gt() {
|
||||
let slice = cursor.slice(&target, Bias::Left, text);
|
||||
layers.push_tree(slice, text);
|
||||
layers.append(slice, text);
|
||||
}
|
||||
}
|
||||
// If this layer follows all of the edits, then preserve it and any
|
||||
@ -303,7 +303,7 @@ impl SyntaxSnapshot {
|
||||
Bias::Left,
|
||||
text,
|
||||
);
|
||||
layers.push_tree(slice, text);
|
||||
layers.append(slice, text);
|
||||
continue;
|
||||
};
|
||||
|
||||
@ -369,7 +369,7 @@ impl SyntaxSnapshot {
|
||||
cursor.next(text);
|
||||
}
|
||||
|
||||
layers.push_tree(cursor.suffix(&text), &text);
|
||||
layers.append(cursor.suffix(&text), &text);
|
||||
drop(cursor);
|
||||
self.layers = layers;
|
||||
}
|
||||
@ -478,7 +478,7 @@ impl SyntaxSnapshot {
|
||||
if bounded_position.cmp(&cursor.start(), &text).is_gt() {
|
||||
let slice = cursor.slice(&bounded_position, Bias::Left, text);
|
||||
if !slice.is_empty() {
|
||||
layers.push_tree(slice, &text);
|
||||
layers.append(slice, &text);
|
||||
if changed_regions.prune(cursor.end(text), text) {
|
||||
done = false;
|
||||
}
|
||||
|
@ -1470,7 +1470,7 @@ impl Snapshot {
|
||||
break;
|
||||
}
|
||||
}
|
||||
new_entries_by_path.push_tree(cursor.suffix(&()), &());
|
||||
new_entries_by_path.append(cursor.suffix(&()), &());
|
||||
new_entries_by_path
|
||||
};
|
||||
|
||||
@ -2259,7 +2259,7 @@ impl BackgroundScannerState {
|
||||
let mut cursor = self.snapshot.entries_by_path.cursor::<TraversalProgress>();
|
||||
new_entries = cursor.slice(&TraversalTarget::Path(path), Bias::Left, &());
|
||||
removed_entries = cursor.slice(&TraversalTarget::PathSuccessor(path), Bias::Left, &());
|
||||
new_entries.push_tree(cursor.suffix(&()), &());
|
||||
new_entries.append(cursor.suffix(&()), &());
|
||||
}
|
||||
self.snapshot.entries_by_path = new_entries;
|
||||
|
||||
|
@ -53,7 +53,7 @@ impl Rope {
|
||||
}
|
||||
}
|
||||
|
||||
self.chunks.push_tree(chunks.suffix(&()), &());
|
||||
self.chunks.append(chunks.suffix(&()), &());
|
||||
self.check_invariants();
|
||||
}
|
||||
|
||||
|
@ -669,7 +669,7 @@ impl<'a, T: Item> SeekAggregate<'a, T> for () {
|
||||
impl<'a, T: Item> SeekAggregate<'a, T> for SliceSeekAggregate<T> {
|
||||
fn begin_leaf(&mut self) {}
|
||||
fn end_leaf(&mut self, cx: &<T::Summary as Summary>::Context) {
|
||||
self.tree.push_tree(
|
||||
self.tree.append(
|
||||
SumTree(Arc::new(Node::Leaf {
|
||||
summary: mem::take(&mut self.leaf_summary),
|
||||
items: mem::take(&mut self.leaf_items),
|
||||
@ -689,7 +689,7 @@ impl<'a, T: Item> SeekAggregate<'a, T> for SliceSeekAggregate<T> {
|
||||
_: &T::Summary,
|
||||
cx: &<T::Summary as Summary>::Context,
|
||||
) {
|
||||
self.tree.push_tree(tree.clone(), cx);
|
||||
self.tree.append(tree.clone(), cx);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -268,7 +268,7 @@ impl<T: Item> SumTree<T> {
|
||||
|
||||
for item in iter {
|
||||
if leaf.is_some() && leaf.as_ref().unwrap().items().len() == 2 * TREE_BASE {
|
||||
self.push_tree(SumTree(Arc::new(leaf.take().unwrap())), cx);
|
||||
self.append(SumTree(Arc::new(leaf.take().unwrap())), cx);
|
||||
}
|
||||
|
||||
if leaf.is_none() {
|
||||
@ -295,13 +295,13 @@ impl<T: Item> SumTree<T> {
|
||||
}
|
||||
|
||||
if leaf.is_some() {
|
||||
self.push_tree(SumTree(Arc::new(leaf.take().unwrap())), cx);
|
||||
self.append(SumTree(Arc::new(leaf.take().unwrap())), cx);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn push(&mut self, item: T, cx: &<T::Summary as Summary>::Context) {
|
||||
let summary = item.summary();
|
||||
self.push_tree(
|
||||
self.append(
|
||||
SumTree(Arc::new(Node::Leaf {
|
||||
summary: summary.clone(),
|
||||
items: ArrayVec::from_iter(Some(item)),
|
||||
@ -311,11 +311,11 @@ impl<T: Item> SumTree<T> {
|
||||
);
|
||||
}
|
||||
|
||||
pub fn push_tree(&mut self, other: Self, cx: &<T::Summary as Summary>::Context) {
|
||||
pub fn append(&mut self, other: Self, cx: &<T::Summary as Summary>::Context) {
|
||||
if !other.0.is_leaf() || !other.0.items().is_empty() {
|
||||
if self.0.height() < other.0.height() {
|
||||
for tree in other.0.child_trees() {
|
||||
self.push_tree(tree.clone(), cx);
|
||||
self.append(tree.clone(), cx);
|
||||
}
|
||||
} else if let Some(split_tree) = self.push_tree_recursive(other, cx) {
|
||||
*self = Self::from_child_trees(self.clone(), split_tree, cx);
|
||||
@ -512,7 +512,7 @@ impl<T: KeyedItem> SumTree<T> {
|
||||
}
|
||||
}
|
||||
new_tree.push(item, cx);
|
||||
new_tree.push_tree(cursor.suffix(cx), cx);
|
||||
new_tree.append(cursor.suffix(cx), cx);
|
||||
new_tree
|
||||
};
|
||||
replaced
|
||||
@ -529,7 +529,7 @@ impl<T: KeyedItem> SumTree<T> {
|
||||
cursor.next(cx);
|
||||
}
|
||||
}
|
||||
new_tree.push_tree(cursor.suffix(cx), cx);
|
||||
new_tree.append(cursor.suffix(cx), cx);
|
||||
new_tree
|
||||
};
|
||||
removed
|
||||
@ -563,7 +563,7 @@ impl<T: KeyedItem> SumTree<T> {
|
||||
{
|
||||
new_tree.extend(buffered_items.drain(..), cx);
|
||||
let slice = cursor.slice(&new_key, Bias::Left, cx);
|
||||
new_tree.push_tree(slice, cx);
|
||||
new_tree.append(slice, cx);
|
||||
old_item = cursor.item();
|
||||
}
|
||||
|
||||
@ -583,7 +583,7 @@ impl<T: KeyedItem> SumTree<T> {
|
||||
}
|
||||
|
||||
new_tree.extend(buffered_items, cx);
|
||||
new_tree.push_tree(cursor.suffix(cx), cx);
|
||||
new_tree.append(cursor.suffix(cx), cx);
|
||||
new_tree
|
||||
};
|
||||
|
||||
@ -719,7 +719,7 @@ mod tests {
|
||||
let mut tree2 = SumTree::new();
|
||||
tree2.extend(50..100, &());
|
||||
|
||||
tree1.push_tree(tree2, &());
|
||||
tree1.append(tree2, &());
|
||||
assert_eq!(
|
||||
tree1.items(&()),
|
||||
(0..20).chain(50..100).collect::<Vec<u8>>()
|
||||
@ -766,7 +766,7 @@ mod tests {
|
||||
let mut new_tree = cursor.slice(&Count(splice_start), Bias::Right, &());
|
||||
new_tree.extend(new_items, &());
|
||||
cursor.seek(&Count(splice_end), Bias::Right, &());
|
||||
new_tree.push_tree(cursor.slice(&tree_end, Bias::Right, &()), &());
|
||||
new_tree.append(cursor.slice(&tree_end, Bias::Right, &()), &());
|
||||
new_tree
|
||||
};
|
||||
|
||||
|
@ -67,7 +67,7 @@ impl<K: Clone + Debug + Default + Ord, V: Clone + Debug> TreeMap<K, V> {
|
||||
removed = Some(cursor.item().unwrap().value.clone());
|
||||
cursor.next(&());
|
||||
}
|
||||
new_tree.push_tree(cursor.suffix(&()), &());
|
||||
new_tree.append(cursor.suffix(&()), &());
|
||||
drop(cursor);
|
||||
self.0 = new_tree;
|
||||
removed
|
||||
@ -79,7 +79,7 @@ impl<K: Clone + Debug + Default + Ord, V: Clone + Debug> TreeMap<K, V> {
|
||||
let mut cursor = self.0.cursor::<MapKeyRef<'_, K>>();
|
||||
let mut new_tree = cursor.slice(&start, Bias::Left, &());
|
||||
cursor.seek(&end, Bias::Left, &());
|
||||
new_tree.push_tree(cursor.suffix(&()), &());
|
||||
new_tree.append(cursor.suffix(&()), &());
|
||||
drop(cursor);
|
||||
self.0 = new_tree;
|
||||
}
|
||||
@ -117,7 +117,7 @@ impl<K: Clone + Debug + Default + Ord, V: Clone + Debug> TreeMap<K, V> {
|
||||
new_tree.push(updated, &());
|
||||
cursor.next(&());
|
||||
}
|
||||
new_tree.push_tree(cursor.suffix(&()), &());
|
||||
new_tree.append(cursor.suffix(&()), &());
|
||||
drop(cursor);
|
||||
self.0 = new_tree;
|
||||
result
|
||||
|
@ -600,7 +600,7 @@ impl Buffer {
|
||||
let mut old_fragments = self.fragments.cursor::<FragmentTextSummary>();
|
||||
let mut new_fragments =
|
||||
old_fragments.slice(&edits.peek().unwrap().0.start, Bias::Right, &None);
|
||||
new_ropes.push_tree(new_fragments.summary().text);
|
||||
new_ropes.append(new_fragments.summary().text);
|
||||
|
||||
let mut fragment_start = old_fragments.start().visible;
|
||||
for (range, new_text) in edits {
|
||||
@ -625,8 +625,8 @@ impl Buffer {
|
||||
}
|
||||
|
||||
let slice = old_fragments.slice(&range.start, Bias::Right, &None);
|
||||
new_ropes.push_tree(slice.summary().text);
|
||||
new_fragments.push_tree(slice, &None);
|
||||
new_ropes.append(slice.summary().text);
|
||||
new_fragments.append(slice, &None);
|
||||
fragment_start = old_fragments.start().visible;
|
||||
}
|
||||
|
||||
@ -728,8 +728,8 @@ impl Buffer {
|
||||
}
|
||||
|
||||
let suffix = old_fragments.suffix(&None);
|
||||
new_ropes.push_tree(suffix.summary().text);
|
||||
new_fragments.push_tree(suffix, &None);
|
||||
new_ropes.append(suffix.summary().text);
|
||||
new_fragments.append(suffix, &None);
|
||||
let (visible_text, deleted_text) = new_ropes.finish();
|
||||
drop(old_fragments);
|
||||
|
||||
@ -828,7 +828,7 @@ impl Buffer {
|
||||
Bias::Left,
|
||||
&cx,
|
||||
);
|
||||
new_ropes.push_tree(new_fragments.summary().text);
|
||||
new_ropes.append(new_fragments.summary().text);
|
||||
|
||||
let mut fragment_start = old_fragments.start().0.full_offset();
|
||||
for (range, new_text) in edits {
|
||||
@ -854,8 +854,8 @@ impl Buffer {
|
||||
|
||||
let slice =
|
||||
old_fragments.slice(&VersionedFullOffset::Offset(range.start), Bias::Left, &cx);
|
||||
new_ropes.push_tree(slice.summary().text);
|
||||
new_fragments.push_tree(slice, &None);
|
||||
new_ropes.append(slice.summary().text);
|
||||
new_fragments.append(slice, &None);
|
||||
fragment_start = old_fragments.start().0.full_offset();
|
||||
}
|
||||
|
||||
@ -986,8 +986,8 @@ impl Buffer {
|
||||
}
|
||||
|
||||
let suffix = old_fragments.suffix(&cx);
|
||||
new_ropes.push_tree(suffix.summary().text);
|
||||
new_fragments.push_tree(suffix, &None);
|
||||
new_ropes.append(suffix.summary().text);
|
||||
new_fragments.append(suffix, &None);
|
||||
let (visible_text, deleted_text) = new_ropes.finish();
|
||||
drop(old_fragments);
|
||||
|
||||
@ -1056,8 +1056,8 @@ impl Buffer {
|
||||
|
||||
for fragment_id in self.fragment_ids_for_edits(undo.counts.keys()) {
|
||||
let preceding_fragments = old_fragments.slice(&Some(fragment_id), Bias::Left, &None);
|
||||
new_ropes.push_tree(preceding_fragments.summary().text);
|
||||
new_fragments.push_tree(preceding_fragments, &None);
|
||||
new_ropes.append(preceding_fragments.summary().text);
|
||||
new_fragments.append(preceding_fragments, &None);
|
||||
|
||||
if let Some(fragment) = old_fragments.item() {
|
||||
let mut fragment = fragment.clone();
|
||||
@ -1087,8 +1087,8 @@ impl Buffer {
|
||||
}
|
||||
|
||||
let suffix = old_fragments.suffix(&None);
|
||||
new_ropes.push_tree(suffix.summary().text);
|
||||
new_fragments.push_tree(suffix, &None);
|
||||
new_ropes.append(suffix.summary().text);
|
||||
new_fragments.append(suffix, &None);
|
||||
|
||||
drop(old_fragments);
|
||||
let (visible_text, deleted_text) = new_ropes.finish();
|
||||
@ -2070,7 +2070,7 @@ impl<'a> RopeBuilder<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
fn push_tree(&mut self, len: FragmentTextSummary) {
|
||||
fn append(&mut self, len: FragmentTextSummary) {
|
||||
self.push(len.visible, true, true);
|
||||
self.push(len.deleted, false, false);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user