History

rope: Assert utf8 boundary of start of `Chunks::new` range (#40253)

We seem to run into panics in related code, so better assert early Release Notes: - N/A *or* Added/Fixed/Improved ...

Lukas Wirth committed 1 year ago

Commit ec0eeaf1 parent 37633541 file · +6 −0Browse files

Unified · Split

crates/rope/src/rope.rs+6−0
@@ -673,6 +673,12 @@ impl<'a> Chunks<'a> { · 672 unmodified lines
673 chunks.seek(&range.start, Bias::Right);673 chunks.seek(&range.start, Bias::Right);
674 range.start674 range.start
675 };675 };
676 let chunk_offset = offset - chunks.start();
677 if let Some(chunk) = chunks.item()
678 && !chunk.text.is_char_boundary(chunk_offset)
679 {
680 panic!("byte index {} is not a char boundary", offset);
681 }
676 Self {682 Self {
677 chunks,683 chunks,
678 range,684 range,