Ensure TabMap
works correctly when there are folds
This commit is contained in:
parent
9ba24794c7
commit
5a9dea5299
1 changed files with 15 additions and 7 deletions
|
@ -467,14 +467,22 @@ mod tests {
|
||||||
let text = RandomCharIter::new(&mut rng).take(len).collect::<String>();
|
let text = RandomCharIter::new(&mut rng).take(len).collect::<String>();
|
||||||
Buffer::new(0, text, cx)
|
Buffer::new(0, text, cx)
|
||||||
});
|
});
|
||||||
let (_, folds_snapshot) = FoldMap::new(buffer.clone(), cx);
|
log::info!("Buffer text: {:?}", buffer.read(cx).text());
|
||||||
|
|
||||||
|
let (mut fold_map, _) = FoldMap::new(buffer.clone(), cx);
|
||||||
|
fold_map.randomly_mutate(&mut rng, cx);
|
||||||
|
let (folds_snapshot, _) = fold_map.read(cx);
|
||||||
|
log::info!("FoldMap text: {:?}", folds_snapshot.text());
|
||||||
|
|
||||||
let (_, tabs_snapshot) = TabMap::new(folds_snapshot.clone(), tab_size);
|
let (_, tabs_snapshot) = TabMap::new(folds_snapshot.clone(), tab_size);
|
||||||
let text = Rope::from(tabs_snapshot.text().as_str());
|
let text = Rope::from(tabs_snapshot.text().as_str());
|
||||||
log::info!("Tab size: {}", tab_size);
|
log::info!(
|
||||||
log::info!("Buffer text: {:?}", buffer.read(cx).text());
|
"TabMap text (tab size: {}): {:?}",
|
||||||
log::info!("FoldMap text: {:?}", folds_snapshot.text());
|
tab_size,
|
||||||
log::info!("TabMap text: {:?}", tabs_snapshot.text());
|
tabs_snapshot.text(),
|
||||||
for _ in 0..1 {
|
);
|
||||||
|
|
||||||
|
for _ in 0..5 {
|
||||||
let end_row = rng.gen_range(0..=text.max_point().row);
|
let end_row = rng.gen_range(0..=text.max_point().row);
|
||||||
let end_column = rng.gen_range(0..=text.line_len(end_row));
|
let end_column = rng.gen_range(0..=text.line_len(end_row));
|
||||||
let mut end = TabPoint(text.clip_point(Point::new(end_row, end_column), Bias::Right));
|
let mut end = TabPoint(text.clip_point(Point::new(end_row, end_column), Bias::Right));
|
||||||
|
@ -490,7 +498,7 @@ mod tests {
|
||||||
.chunks_in_range(text.point_to_offset(start.0)..text.point_to_offset(end.0))
|
.chunks_in_range(text.point_to_offset(start.0)..text.point_to_offset(end.0))
|
||||||
.collect::<String>();
|
.collect::<String>();
|
||||||
let expected_summary = TextSummary::from(expected_text.as_str());
|
let expected_summary = TextSummary::from(expected_text.as_str());
|
||||||
log::info!("Slicing {:?}..{:?} (text: {:?})", start, end, text);
|
log::info!("slicing {:?}..{:?} (text: {:?})", start, end, text);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
expected_text,
|
expected_text,
|
||||||
tabs_snapshot
|
tabs_snapshot
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue