Use new multibuffer excerpts in find-all-references and friends (#27876)
Release Notes: - N/A --------- Co-authored-by: Kirill Bulatov <mail4score@gmail.com>
This commit is contained in:
parent
e7290df02b
commit
9bc4697a33
7 changed files with 54 additions and 139 deletions
|
@ -147,7 +147,7 @@ pub use multi_buffer::{
|
|||
};
|
||||
use multi_buffer::{
|
||||
ExcerptInfo, ExpandExcerptDirection, MultiBufferDiffHunk, MultiBufferPoint, MultiBufferRow,
|
||||
MultiOrSingleBufferOffsetRange, ToOffsetUtf16,
|
||||
MultiOrSingleBufferOffsetRange, PathKey, ToOffsetUtf16,
|
||||
};
|
||||
use parking_lot::Mutex;
|
||||
use project::{
|
||||
|
@ -5035,17 +5035,19 @@ impl Editor {
|
|||
let excerpt_buffer = cx.new(|cx| {
|
||||
let mut multibuffer = MultiBuffer::new(Capability::ReadWrite).with_title(title);
|
||||
for (buffer_handle, transaction) in &entries {
|
||||
let buffer = buffer_handle.read(cx);
|
||||
ranges_to_highlight.extend(
|
||||
multibuffer.push_excerpts_with_context_lines(
|
||||
buffer_handle.clone(),
|
||||
buffer
|
||||
.edited_ranges_for_transaction::<usize>(transaction)
|
||||
.collect(),
|
||||
DEFAULT_MULTIBUFFER_CONTEXT,
|
||||
cx,
|
||||
),
|
||||
let edited_ranges = buffer_handle
|
||||
.read(cx)
|
||||
.edited_ranges_for_transaction::<Point>(transaction)
|
||||
.collect::<Vec<_>>();
|
||||
let (ranges, _) = multibuffer.set_excerpts_for_path(
|
||||
PathKey::for_buffer(buffer_handle, cx),
|
||||
buffer_handle.clone(),
|
||||
edited_ranges,
|
||||
DEFAULT_MULTIBUFFER_CONTEXT,
|
||||
cx,
|
||||
);
|
||||
|
||||
ranges_to_highlight.extend(ranges);
|
||||
}
|
||||
multibuffer.push_transaction(entries.iter().map(|(b, t)| (b, t)), cx);
|
||||
multibuffer
|
||||
|
@ -13531,7 +13533,7 @@ impl Editor {
|
|||
// If there are multiple definitions, open them in a multibuffer
|
||||
locations.sort_by_key(|location| location.buffer.read(cx).remote_id());
|
||||
let mut locations = locations.into_iter().peekable();
|
||||
let mut ranges = Vec::new();
|
||||
let mut ranges: Vec<Range<Anchor>> = Vec::new();
|
||||
let capability = workspace.project().read(cx).capability();
|
||||
|
||||
let excerpt_buffer = cx.new(|cx| {
|
||||
|
@ -13539,12 +13541,12 @@ impl Editor {
|
|||
while let Some(location) = locations.next() {
|
||||
let buffer = location.buffer.read(cx);
|
||||
let mut ranges_for_buffer = Vec::new();
|
||||
let range = location.range.to_offset(buffer);
|
||||
let range = location.range.to_point(buffer);
|
||||
ranges_for_buffer.push(range.clone());
|
||||
|
||||
while let Some(next_location) = locations.peek() {
|
||||
if next_location.buffer == location.buffer {
|
||||
ranges_for_buffer.push(next_location.range.to_offset(buffer));
|
||||
ranges_for_buffer.push(next_location.range.to_point(buffer));
|
||||
locations.next();
|
||||
} else {
|
||||
break;
|
||||
|
@ -13552,12 +13554,14 @@ impl Editor {
|
|||
}
|
||||
|
||||
ranges_for_buffer.sort_by_key(|range| (range.start, Reverse(range.end)));
|
||||
ranges.extend(multibuffer.push_excerpts_with_context_lines(
|
||||
let (new_ranges, _) = multibuffer.set_excerpts_for_path(
|
||||
PathKey::for_buffer(&location.buffer, cx),
|
||||
location.buffer.clone(),
|
||||
ranges_for_buffer,
|
||||
DEFAULT_MULTIBUFFER_CONTEXT,
|
||||
cx,
|
||||
))
|
||||
);
|
||||
ranges.extend(new_ranges)
|
||||
}
|
||||
|
||||
multibuffer.with_title(title)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue