Fix inlay map tests

Co-Authored-By: Antonio Scandurra <antonio@zed.dev>
This commit is contained in:
Kirill Bulatov 2023-06-14 17:48:46 +03:00
parent b231fa47af
commit 02e124cec4
2 changed files with 116 additions and 141 deletions

View file

@ -85,6 +85,24 @@ impl Anchor {
{
snapshot.summary_for_anchor(self)
}
pub fn is_valid(&self, snapshot: &MultiBufferSnapshot) -> bool {
if *self == Anchor::min() || *self == Anchor::max() {
true
} else if let Some(excerpt) = snapshot.excerpt(self.excerpt_id) {
self.text_anchor.is_valid(&excerpt.buffer)
&& self
.text_anchor
.cmp(&excerpt.range.context.start, &excerpt.buffer)
.is_ge()
&& self
.text_anchor
.cmp(&excerpt.range.context.end, &excerpt.buffer)
.is_le()
} else {
false
}
}
}
impl ToOffset for Anchor {