Start removing callers of legacy excerpt APIs (#50144)
Paving the way to remove `ExcerptId`. Done in this PR: - Unshipped the stack trace view - Get rid of `push_excerpts` - Get rid of some callers of `remove_excerpts` We still need to remove some calls to `remove_excerpts` and other APIs, especially in `randomly_edit_excerpts` and collaboration. Release Notes: - The stack trace multibuffer view has been removed. --------- Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
This commit is contained in:
1 parent
8b2829e112
commit
be5763632d
23 files changed
+917
-1436
No files matched your search
@@ -1160,12 +1160,11 @@ impl MultiBuffer {
|
||||
},
|
||||
);
|
||||
this.singleton = true;
|
||||
let buffer_id = buffer.read(cx).remote_id();
|
||||
this.push_excerpts(
|
||||
buffer,
|
||||
[ExcerptRange::new(text::Anchor::min_max_range_for_buffer(
|
||||
buffer_id,
|
||||
))],
|
||||
this.set_excerpts_for_path(
|
||||
PathKey::sorted(0),
|
||||
buffer.clone(),
|
||||
[Point::zero()..buffer.read(cx).max_point()],
|
||||
0,
|
||||
cx,
|
||||
);
|
||||
this
|
||||
@@ -1734,18 +1733,6 @@ impl MultiBuffer {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn push_excerpts<O>(
|
||||
&mut self,
|
||||
buffer: Entity<Buffer>,
|
||||
ranges: impl IntoIterator<Item = ExcerptRange<O>>,
|
||||
cx: &mut Context<Self>,
|
||||
) -> Vec<ExcerptId>
|
||||
where
|
||||
O: text::ToOffset,
|
||||
{
|
||||
self.insert_excerpts_after(ExcerptId::max(), buffer, ranges, cx)
|
||||
}
|
||||
|
||||
#[instrument(skip_all)]
|
||||
fn merge_excerpt_ranges<'a>(
|
||||
expanded_ranges: impl IntoIterator<Item = &'a ExcerptRange<Point>> + 'a,
|
||||
@@ -3749,11 +3736,21 @@ impl MultiBuffer {
|
||||
cx: &mut gpui::App,
|
||||
) -> Entity<Self> {
|
||||
let multi = cx.new(|_| Self::new(Capability::ReadWrite));
|
||||
for (text, ranges) in excerpts {
|
||||
for (ix, (text, ranges)) in excerpts.into_iter().enumerate() {
|
||||
let buffer = cx.new(|cx| Buffer::local(text, cx));
|
||||
let excerpt_ranges = ranges.into_iter().map(ExcerptRange::new);
|
||||
let snapshot = buffer.read(cx).snapshot();
|
||||
let excerpt_ranges = ranges
|
||||
.into_iter()
|
||||
.map(ExcerptRange::new)
|
||||
.collect::<Vec<_>>();
|
||||
multi.update(cx, |multi, cx| {
|
||||
multi.push_excerpts(buffer, excerpt_ranges, cx)
|
||||
multi.set_excerpt_ranges_for_path(
|
||||
PathKey::sorted(ix as u64),
|
||||
buffer,
|
||||
&snapshot,
|
||||
excerpt_ranges,
|
||||
cx,
|
||||
)
|
||||
});
|
||||
}
|
||||
|
||||
@@ -3887,7 +3884,8 @@ impl MultiBuffer {
|
||||
.collect::<Vec<_>>()
|
||||
);
|
||||
|
||||
let excerpt_id = self.push_excerpts(buffer_handle.clone(), ranges, cx);
|
||||
let excerpt_id =
|
||||
self.insert_excerpts_after(ExcerptId::max(), buffer_handle, ranges, cx);
|
||||
log::info!("Inserted with ids: {:?}", excerpt_id);
|
||||
} else {
|
||||
let remove_count = rng.random_range(1..=excerpt_ids.len());
|
||||
|
||||
Reference in new issue
Block a user