Introduce Rope::clip_offset_utf16

This commit is contained in:
Antonio Scandurra 2022-07-25 15:02:45 +02:00
parent bb55d654ce
commit c46be992e0
3 changed files with 59 additions and 14 deletions

View file

@ -1888,7 +1888,7 @@ impl MultiBufferSnapshot {
.offset_to_offset_utf16(excerpt_start_offset + overshoot);
*start_offset_utf16 + (buffer_offset_utf16 - excerpt_start_offset_utf16)
} else {
OffsetUtf16(self.excerpts.summary().text.len_utf16)
self.excerpts.summary().text.len_utf16
}
}
@ -2935,7 +2935,7 @@ impl<'a> sum_tree::SeekTarget<'a, ExcerptSummary, ExcerptSummary> for Option<&'a
impl<'a> sum_tree::Dimension<'a, ExcerptSummary> for OffsetUtf16 {
fn add_summary(&mut self, summary: &'a ExcerptSummary, _: &()) {
self.0 += summary.text.len_utf16;
*self += summary.text.len_utf16;
}
}