Enhance randomized test to verify SuggestionMap::{chunks,sync}

Co-Authored-By: Max Brunsfeld <max@zed.dev>
This commit is contained in:
Antonio Scandurra 2023-03-20 19:17:23 +01:00
parent 4d6726ef39
commit f44549eb29
2 changed files with 81 additions and 26 deletions

View file

@ -31,7 +31,7 @@ const CHUNK_BASE: usize = 16;
/// hash being equivalent to hashing all the text contained in the [Rope] at once.
pub type RopeFingerprint = HashMatrix;
#[derive(Clone, Default, Debug)]
#[derive(Clone, Default)]
pub struct Rope {
chunks: SumTree<Chunk>,
}
@ -389,6 +389,22 @@ impl fmt::Display for Rope {
}
}
impl fmt::Debug for Rope {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
use std::fmt::Write as _;
write!(f, "\"")?;
let mut format_string = String::new();
for chunk in self.chunks() {
write!(&mut format_string, "{:?}", chunk)?;
write!(f, "{}", &format_string[1..format_string.len() - 1])?;
format_string.clear();
}
write!(f, "\"")?;
Ok(())
}
}
pub struct Cursor<'a> {
rope: &'a Rope,
chunks: sum_tree::Cursor<'a, Chunk, usize>,