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
|
@ -710,8 +710,9 @@ fn test_expand_excerpts(cx: &mut App) {
|
|||
let multibuffer = cx.new(|_| MultiBuffer::new(Capability::ReadWrite));
|
||||
|
||||
multibuffer.update(cx, |multibuffer, cx| {
|
||||
multibuffer.push_excerpts_with_context_lines(
|
||||
buffer.clone(),
|
||||
multibuffer.set_excerpts_for_path(
|
||||
PathKey::for_buffer(&buffer, cx),
|
||||
buffer,
|
||||
vec![
|
||||
// Note that in this test, this first excerpt
|
||||
// does not contain a new line
|
||||
|
@ -765,7 +766,6 @@ fn test_expand_excerpts(cx: &mut App) {
|
|||
"ccc\n", //
|
||||
"ddd\n", //
|
||||
"eee\n", //
|
||||
"fff\n", // End of excerpt
|
||||
"fff\n", //
|
||||
"ggg\n", //
|
||||
"hhh\n", //
|
||||
|
@ -780,59 +780,6 @@ fn test_expand_excerpts(cx: &mut App) {
|
|||
);
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_push_excerpts_with_context_lines(cx: &mut App) {
|
||||
let buffer = cx.new(|cx| Buffer::local(sample_text(20, 3, 'a'), cx));
|
||||
let multibuffer = cx.new(|_| MultiBuffer::new(Capability::ReadWrite));
|
||||
let anchor_ranges = multibuffer.update(cx, |multibuffer, cx| {
|
||||
multibuffer.push_excerpts_with_context_lines(
|
||||
buffer.clone(),
|
||||
vec![
|
||||
// Note that in this test, this first excerpt
|
||||
// does contain a new line
|
||||
Point::new(3, 2)..Point::new(4, 2),
|
||||
Point::new(7, 1)..Point::new(7, 3),
|
||||
Point::new(15, 0)..Point::new(15, 0),
|
||||
],
|
||||
2,
|
||||
cx,
|
||||
)
|
||||
});
|
||||
|
||||
let snapshot = multibuffer.read(cx).snapshot(cx);
|
||||
assert_eq!(
|
||||
snapshot.text(),
|
||||
concat!(
|
||||
"bbb\n", // Preserve newlines
|
||||
"ccc\n", //
|
||||
"ddd\n", //
|
||||
"eee\n", //
|
||||
"fff\n", //
|
||||
"ggg\n", //
|
||||
"hhh\n", //
|
||||
"iii\n", //
|
||||
"jjj\n", //
|
||||
"nnn\n", //
|
||||
"ooo\n", //
|
||||
"ppp\n", //
|
||||
"qqq\n", //
|
||||
"rrr", //
|
||||
)
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
anchor_ranges
|
||||
.iter()
|
||||
.map(|range| range.to_point(&snapshot))
|
||||
.collect::<Vec<_>>(),
|
||||
vec![
|
||||
Point::new(2, 2)..Point::new(3, 2),
|
||||
Point::new(6, 1)..Point::new(6, 3),
|
||||
Point::new(11, 0)..Point::new(11, 0)
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
#[gpui::test(iterations = 100)]
|
||||
async fn test_push_multiple_excerpts_with_context_lines(cx: &mut TestAppContext) {
|
||||
let buffer_1 = cx.new(|cx| Buffer::local(sample_text(20, 3, 'a'), cx));
|
||||
|
@ -1513,7 +1460,7 @@ fn test_set_excerpts_for_buffer_ordering(cx: &mut TestAppContext) {
|
|||
cx,
|
||||
)
|
||||
});
|
||||
let path1: PathKey = PathKey::namespaced("0", Path::new("/").into());
|
||||
let path1: PathKey = PathKey::namespaced(0, Path::new("/").into());
|
||||
|
||||
let multibuffer = cx.new(|_| MultiBuffer::new(Capability::ReadWrite));
|
||||
multibuffer.update(cx, |multibuffer, cx| {
|
||||
|
@ -1539,13 +1486,11 @@ fn test_set_excerpts_for_buffer_ordering(cx: &mut TestAppContext) {
|
|||
one
|
||||
two
|
||||
two.five
|
||||
three
|
||||
-----
|
||||
four
|
||||
five
|
||||
six
|
||||
seven
|
||||
eight
|
||||
-----
|
||||
nine
|
||||
ten
|
||||
|
@ -1561,8 +1506,8 @@ fn test_set_excerpts_for_buffer_ordering(cx: &mut TestAppContext) {
|
|||
path1.clone(),
|
||||
buf1.clone(),
|
||||
vec![
|
||||
Point::row_range(0..2),
|
||||
Point::row_range(5..6),
|
||||
Point::row_range(0..3),
|
||||
Point::row_range(5..7),
|
||||
Point::row_range(10..11),
|
||||
],
|
||||
1,
|
||||
|
@ -1611,7 +1556,7 @@ fn test_set_excerpts_for_buffer(cx: &mut TestAppContext) {
|
|||
cx,
|
||||
)
|
||||
});
|
||||
let path1: PathKey = PathKey::namespaced("0", Path::new("/").into());
|
||||
let path1: PathKey = PathKey::namespaced(0, Path::new("/").into());
|
||||
let buf2 = cx.new(|cx| {
|
||||
Buffer::local(
|
||||
indoc! {
|
||||
|
@ -1630,7 +1575,7 @@ fn test_set_excerpts_for_buffer(cx: &mut TestAppContext) {
|
|||
cx,
|
||||
)
|
||||
});
|
||||
let path2 = PathKey::namespaced("x", Path::new("/").into());
|
||||
let path2 = PathKey::namespaced(1, Path::new("/").into());
|
||||
|
||||
let multibuffer = cx.new(|_| MultiBuffer::new(Capability::ReadWrite));
|
||||
multibuffer.update(cx, |multibuffer, cx| {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue