wip
This commit is contained in:
@@ -7292,8 +7292,9 @@ pub fn randomly_mutate_multibuffer_with_diffs(
|
||||
}
|
||||
|
||||
let excerpt_ids = multibuffer.read_with(cx, |multibuffer, _| multibuffer.excerpt_ids());
|
||||
// TODO cover changes of base text?
|
||||
match rng.random_range(0..100) {
|
||||
0..=14 if !buffers.is_empty() => {
|
||||
0..=49 if !buffers.is_empty() => {
|
||||
let buffer = buffers.choose(rng).unwrap();
|
||||
buffer.update(cx, |buf, cx| {
|
||||
let edit_count = rng.random_range(1..5);
|
||||
@@ -7302,41 +7303,7 @@ pub fn randomly_mutate_multibuffer_with_diffs(
|
||||
*needs_diff_calculation = true;
|
||||
});
|
||||
}
|
||||
15..=19 if !excerpt_ids.is_empty() => {
|
||||
multibuffer.update(cx, |multibuffer, cx| {
|
||||
let ids = multibuffer.excerpt_ids();
|
||||
let mut excerpts = HashSet::default();
|
||||
for _ in 0..rng.random_range(0..ids.len()) {
|
||||
excerpts.extend(ids.choose(rng).copied());
|
||||
}
|
||||
|
||||
let line_count = rng.random_range(0..5);
|
||||
|
||||
log::info!("Expanding excerpts by {line_count} lines");
|
||||
multibuffer.expand_excerpts(
|
||||
excerpts.iter().cloned(),
|
||||
line_count,
|
||||
ExpandExcerptDirection::UpAndDown,
|
||||
cx,
|
||||
);
|
||||
});
|
||||
}
|
||||
// 20..=29 if !excerpt_ids.is_empty() => {
|
||||
// let mut ids_to_remove = vec![];
|
||||
// for _ in 0..rng.random_range(1..=3) {
|
||||
// let Some(id) = excerpt_ids.choose(rng) else {
|
||||
// break;
|
||||
// };
|
||||
// ids_to_remove.push(*id);
|
||||
// }
|
||||
// let snapshot = multibuffer.read_with(cx, |multibuffer, cx| multibuffer.snapshot(cx));
|
||||
// ids_to_remove.sort_unstable_by(|a, b| a.cmp(b, &snapshot));
|
||||
// drop(snapshot);
|
||||
// multibuffer.update(cx, |multibuffer, cx| {
|
||||
// multibuffer.remove_excerpts(ids_to_remove, cx)
|
||||
// });
|
||||
// }
|
||||
56..=85 if *needs_diff_calculation => {
|
||||
50..=69 if *needs_diff_calculation => {
|
||||
multibuffer.update(cx, |multibuffer, cx| {
|
||||
for buffer in buffers {
|
||||
use util::rel_path::rel_path;
|
||||
@@ -7368,7 +7335,25 @@ pub fn randomly_mutate_multibuffer_with_diffs(
|
||||
*needs_diff_calculation = false;
|
||||
});
|
||||
}
|
||||
// TODO cover changes of base text
|
||||
70..=79 if !excerpt_ids.is_empty() => {
|
||||
multibuffer.update(cx, |multibuffer, cx| {
|
||||
let ids = multibuffer.excerpt_ids();
|
||||
let mut excerpts = HashSet::default();
|
||||
for _ in 0..rng.random_range(0..ids.len()) {
|
||||
excerpts.extend(ids.choose(rng).copied());
|
||||
}
|
||||
|
||||
let line_count = rng.random_range(0..5);
|
||||
|
||||
log::info!("Expanding excerpts by {line_count} lines");
|
||||
multibuffer.expand_excerpts(
|
||||
excerpts.iter().cloned(),
|
||||
line_count,
|
||||
ExpandExcerptDirection::UpAndDown,
|
||||
cx,
|
||||
);
|
||||
});
|
||||
}
|
||||
_ => {
|
||||
let mut base_text = util::RandomCharIter::new(&mut *rng)
|
||||
.take(256)
|
||||
@@ -7383,29 +7368,6 @@ pub fn randomly_mutate_multibuffer_with_diffs(
|
||||
buffers.push(buffer);
|
||||
let buffer_handle = buffers.last().unwrap();
|
||||
|
||||
// let prev_excerpt_id = multibuffer
|
||||
// .read_with(cx, |multibuffer, cx| multibuffer.excerpt_ids())
|
||||
// .choose(rng)
|
||||
// .copied()
|
||||
// .unwrap_or(ExcerptId::max());
|
||||
|
||||
// let range = buffer_handle.read_with(cx, |buffer, _| {
|
||||
// let end_row = rng.random_range(0..=buffer.max_point().row);
|
||||
// let start_row = rng.random_range(0..=end_row);
|
||||
// let end_ix = buffer.point_to_offset(Point::new(end_row, 0));
|
||||
// let start_ix = buffer.point_to_offset(Point::new(start_row, 0));
|
||||
|
||||
// log::info!(
|
||||
// "Inserting excerpt for buffer {}: {:?}[{:?}] = {:?}",
|
||||
// buffer.remote_id(),
|
||||
// buffer.text(),
|
||||
// start_ix..end_ix,
|
||||
// &buffer.text()[start_ix..end_ix]
|
||||
// );
|
||||
|
||||
// start_ix..end_ix
|
||||
// });
|
||||
|
||||
multibuffer.update(cx, |multibuffer, cx| {
|
||||
let id = buffer_handle.read(cx).remote_id();
|
||||
if multibuffer.diff_for(id).is_none() {
|
||||
@@ -7417,18 +7379,6 @@ pub fn randomly_mutate_multibuffer_with_diffs(
|
||||
});
|
||||
|
||||
*needs_diff_calculation = true;
|
||||
|
||||
// multibuffer.update(cx, |multibuffer, cx| {
|
||||
// multibuffer
|
||||
// .insert_excerpts_after(
|
||||
// prev_excerpt_id,
|
||||
// buffer_handle.clone(),
|
||||
// [ExcerptRange::new(range.clone())],
|
||||
// cx,
|
||||
// )
|
||||
// .pop()
|
||||
// .unwrap()
|
||||
// });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user