Implement MultiBufferSnapshot::contains_str_at

This commit is contained in:
Antonio Scandurra 2021-12-14 17:51:14 +01:00
parent 08e9f3e1e3
commit 358a6ff66c

View file

@ -735,8 +735,14 @@ impl MultiBufferSnapshot {
where
T: ToOffset,
{
let offset = position.to_offset(self);
self.as_singleton().unwrap().contains_str_at(offset, needle)
let position = position.to_offset(self);
position == self.clip_offset(position, Bias::Left)
&& self
.bytes_in_range(position..self.len())
.flatten()
.copied()
.take(needle.len())
.eq(needle.bytes())
}
fn as_singleton(&self) -> Option<&BufferSnapshot> {