Get tests building again
This commit is contained in:
parent
cf72173282
commit
0dedc1f3a4
5 changed files with 38 additions and 15 deletions
|
@ -1813,7 +1813,7 @@ async fn test_git_diff_base_change(
|
||||||
buffer_local_a.read_with(cx_a, |buffer, _| {
|
buffer_local_a.read_with(cx_a, |buffer, _| {
|
||||||
assert_eq!(buffer.diff_base(), Some(diff_base.as_ref()));
|
assert_eq!(buffer.diff_base(), Some(diff_base.as_ref()));
|
||||||
git::diff::assert_hunks(
|
git::diff::assert_hunks(
|
||||||
buffer.snapshot().git_diff_hunks_in_range(0..4, false),
|
buffer.snapshot().git_diff_hunks_in_row_range(0..4, false),
|
||||||
&buffer,
|
&buffer,
|
||||||
&diff_base,
|
&diff_base,
|
||||||
&[(1..2, "", "two\n")],
|
&[(1..2, "", "two\n")],
|
||||||
|
@ -1833,7 +1833,7 @@ async fn test_git_diff_base_change(
|
||||||
buffer_remote_a.read_with(cx_b, |buffer, _| {
|
buffer_remote_a.read_with(cx_b, |buffer, _| {
|
||||||
assert_eq!(buffer.diff_base(), Some(diff_base.as_ref()));
|
assert_eq!(buffer.diff_base(), Some(diff_base.as_ref()));
|
||||||
git::diff::assert_hunks(
|
git::diff::assert_hunks(
|
||||||
buffer.snapshot().git_diff_hunks_in_range(0..4, false),
|
buffer.snapshot().git_diff_hunks_in_row_range(0..4, false),
|
||||||
&buffer,
|
&buffer,
|
||||||
&diff_base,
|
&diff_base,
|
||||||
&[(1..2, "", "two\n")],
|
&[(1..2, "", "two\n")],
|
||||||
|
@ -1857,7 +1857,7 @@ async fn test_git_diff_base_change(
|
||||||
assert_eq!(buffer.diff_base(), Some(new_diff_base.as_ref()));
|
assert_eq!(buffer.diff_base(), Some(new_diff_base.as_ref()));
|
||||||
|
|
||||||
git::diff::assert_hunks(
|
git::diff::assert_hunks(
|
||||||
buffer.snapshot().git_diff_hunks_in_range(0..4, false),
|
buffer.snapshot().git_diff_hunks_in_row_range(0..4, false),
|
||||||
&buffer,
|
&buffer,
|
||||||
&diff_base,
|
&diff_base,
|
||||||
&[(2..3, "", "three\n")],
|
&[(2..3, "", "three\n")],
|
||||||
|
@ -1868,7 +1868,7 @@ async fn test_git_diff_base_change(
|
||||||
buffer_remote_a.read_with(cx_b, |buffer, _| {
|
buffer_remote_a.read_with(cx_b, |buffer, _| {
|
||||||
assert_eq!(buffer.diff_base(), Some(new_diff_base.as_ref()));
|
assert_eq!(buffer.diff_base(), Some(new_diff_base.as_ref()));
|
||||||
git::diff::assert_hunks(
|
git::diff::assert_hunks(
|
||||||
buffer.snapshot().git_diff_hunks_in_range(0..4, false),
|
buffer.snapshot().git_diff_hunks_in_row_range(0..4, false),
|
||||||
&buffer,
|
&buffer,
|
||||||
&diff_base,
|
&diff_base,
|
||||||
&[(2..3, "", "three\n")],
|
&[(2..3, "", "three\n")],
|
||||||
|
@ -1911,7 +1911,7 @@ async fn test_git_diff_base_change(
|
||||||
buffer_local_b.read_with(cx_a, |buffer, _| {
|
buffer_local_b.read_with(cx_a, |buffer, _| {
|
||||||
assert_eq!(buffer.diff_base(), Some(diff_base.as_ref()));
|
assert_eq!(buffer.diff_base(), Some(diff_base.as_ref()));
|
||||||
git::diff::assert_hunks(
|
git::diff::assert_hunks(
|
||||||
buffer.snapshot().git_diff_hunks_in_range(0..4, false),
|
buffer.snapshot().git_diff_hunks_in_row_range(0..4, false),
|
||||||
&buffer,
|
&buffer,
|
||||||
&diff_base,
|
&diff_base,
|
||||||
&[(1..2, "", "two\n")],
|
&[(1..2, "", "two\n")],
|
||||||
|
@ -1931,7 +1931,7 @@ async fn test_git_diff_base_change(
|
||||||
buffer_remote_b.read_with(cx_b, |buffer, _| {
|
buffer_remote_b.read_with(cx_b, |buffer, _| {
|
||||||
assert_eq!(buffer.diff_base(), Some(diff_base.as_ref()));
|
assert_eq!(buffer.diff_base(), Some(diff_base.as_ref()));
|
||||||
git::diff::assert_hunks(
|
git::diff::assert_hunks(
|
||||||
buffer.snapshot().git_diff_hunks_in_range(0..4, false),
|
buffer.snapshot().git_diff_hunks_in_row_range(0..4, false),
|
||||||
&buffer,
|
&buffer,
|
||||||
&diff_base,
|
&diff_base,
|
||||||
&[(1..2, "", "two\n")],
|
&[(1..2, "", "two\n")],
|
||||||
|
@ -1959,12 +1959,12 @@ async fn test_git_diff_base_change(
|
||||||
"{:?}",
|
"{:?}",
|
||||||
buffer
|
buffer
|
||||||
.snapshot()
|
.snapshot()
|
||||||
.git_diff_hunks_in_range(0..4, false)
|
.git_diff_hunks_in_row_range(0..4, false)
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
);
|
);
|
||||||
|
|
||||||
git::diff::assert_hunks(
|
git::diff::assert_hunks(
|
||||||
buffer.snapshot().git_diff_hunks_in_range(0..4, false),
|
buffer.snapshot().git_diff_hunks_in_row_range(0..4, false),
|
||||||
&buffer,
|
&buffer,
|
||||||
&diff_base,
|
&diff_base,
|
||||||
&[(2..3, "", "three\n")],
|
&[(2..3, "", "three\n")],
|
||||||
|
@ -1975,7 +1975,7 @@ async fn test_git_diff_base_change(
|
||||||
buffer_remote_b.read_with(cx_b, |buffer, _| {
|
buffer_remote_b.read_with(cx_b, |buffer, _| {
|
||||||
assert_eq!(buffer.diff_base(), Some(new_diff_base.as_ref()));
|
assert_eq!(buffer.diff_base(), Some(new_diff_base.as_ref()));
|
||||||
git::diff::assert_hunks(
|
git::diff::assert_hunks(
|
||||||
buffer.snapshot().git_diff_hunks_in_range(0..4, false),
|
buffer.snapshot().git_diff_hunks_in_row_range(0..4, false),
|
||||||
&buffer,
|
&buffer,
|
||||||
&diff_base,
|
&diff_base,
|
||||||
&[(2..3, "", "three\n")],
|
&[(2..3, "", "three\n")],
|
||||||
|
|
|
@ -2652,7 +2652,8 @@ impl MultiBufferSnapshot {
|
||||||
let range = excerpt.range.context.clone();
|
let range = excerpt.range.context.clone();
|
||||||
let range_start_row = range.start.to_point(&excerpt.buffer).row;
|
let range_start_row = range.start.to_point(&excerpt.buffer).row;
|
||||||
let range_end_row = range.end.to_point(&excerpt.buffer).row;
|
let range_end_row = range.end.to_point(&excerpt.buffer).row;
|
||||||
let a = Some(excerpt.buffer.git_diff_hunks_in_range(range, reversed).map(
|
|
||||||
|
let hunks = excerpt.buffer.git_diff_hunks_in_range(range, reversed).map(
|
||||||
move |mut hunk| {
|
move |mut hunk| {
|
||||||
hunk.buffer_range.start = hunk.buffer_range.start.max(range_start_row)
|
hunk.buffer_range.start = hunk.buffer_range.start.max(range_start_row)
|
||||||
- range_start_row
|
- range_start_row
|
||||||
|
@ -2662,9 +2663,10 @@ impl MultiBufferSnapshot {
|
||||||
+ lines_advance;
|
+ lines_advance;
|
||||||
hunk
|
hunk
|
||||||
},
|
},
|
||||||
));
|
);
|
||||||
|
|
||||||
lines_advance += summary.text.lines.row;
|
lines_advance += summary.text.lines.row;
|
||||||
a
|
Some(hunks)
|
||||||
})
|
})
|
||||||
.flatten()
|
.flatten()
|
||||||
}
|
}
|
||||||
|
|
|
@ -254,7 +254,7 @@ impl<'a> EditorTestContext<'a> {
|
||||||
|
|
||||||
Actual selections:
|
Actual selections:
|
||||||
{}
|
{}
|
||||||
"},
|
"},
|
||||||
self.assertion_context(),
|
self.assertion_context(),
|
||||||
expected_marked_text,
|
expected_marked_text,
|
||||||
actual_marked_text,
|
actual_marked_text,
|
||||||
|
|
|
@ -71,6 +71,17 @@ impl BufferDiff {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn hunks_in_row_range<'a>(
|
||||||
|
&'a self,
|
||||||
|
range: Range<u32>,
|
||||||
|
buffer: &'a BufferSnapshot,
|
||||||
|
reversed: bool,
|
||||||
|
) -> impl 'a + Iterator<Item = DiffHunk<u32>> {
|
||||||
|
let start = buffer.anchor_before(Point::new(range.start, 0));
|
||||||
|
let end = buffer.anchor_after(Point::new(range.end, 0));
|
||||||
|
self.hunks_in_range(start..end, buffer, reversed)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn hunks_in_range<'a>(
|
pub fn hunks_in_range<'a>(
|
||||||
&'a self,
|
&'a self,
|
||||||
range: Range<Anchor>,
|
range: Range<Anchor>,
|
||||||
|
@ -138,7 +149,9 @@ impl BufferDiff {
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
fn hunks<'a>(&'a self, text: &'a BufferSnapshot) -> impl 'a + Iterator<Item = DiffHunk<u32>> {
|
fn hunks<'a>(&'a self, text: &'a BufferSnapshot) -> impl 'a + Iterator<Item = DiffHunk<u32>> {
|
||||||
self.hunks_in_range(0..u32::MAX, text, false)
|
let start = text.anchor_before(Point::new(0, 0));
|
||||||
|
let end = text.anchor_after(Point::new(u32::MAX, u32::MAX));
|
||||||
|
self.hunks_in_range(start..end, text, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn diff<'a>(head: &'a str, current: &'a str) -> Option<GitPatch<'a>> {
|
fn diff<'a>(head: &'a str, current: &'a str) -> Option<GitPatch<'a>> {
|
||||||
|
@ -352,7 +365,7 @@ mod tests {
|
||||||
assert_eq!(diff.hunks(&buffer).count(), 8);
|
assert_eq!(diff.hunks(&buffer).count(), 8);
|
||||||
|
|
||||||
assert_hunks(
|
assert_hunks(
|
||||||
diff.hunks_in_range(7..12, &buffer, false),
|
diff.hunks_in_row_range(7..12, &buffer, false),
|
||||||
&buffer,
|
&buffer,
|
||||||
&diff_base,
|
&diff_base,
|
||||||
&[
|
&[
|
||||||
|
|
|
@ -2310,6 +2310,14 @@ impl BufferSnapshot {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn git_diff_hunks_in_row_range<'a>(
|
||||||
|
&'a self,
|
||||||
|
range: Range<u32>,
|
||||||
|
reversed: bool,
|
||||||
|
) -> impl 'a + Iterator<Item = git::diff::DiffHunk<u32>> {
|
||||||
|
self.git_diff.hunks_in_row_range(range, self, reversed)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn git_diff_hunks_in_range<'a>(
|
pub fn git_diff_hunks_in_range<'a>(
|
||||||
&'a self,
|
&'a self,
|
||||||
range: Range<Anchor>,
|
range: Range<Anchor>,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue