mirror of
https://github.com/zed-industries/zed.git
synced 2026-05-25 14:44:28 +00:00
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 ...
This commit is contained in:
parent
376335496d
commit
ec0eeaf69d
1 changed files with 6 additions and 0 deletions
|
|
@ -673,6 +673,12 @@ impl<'a> Chunks<'a> {
|
|||
chunks.seek(&range.start, Bias::Right);
|
||||
range.start
|
||||
};
|
||||
let chunk_offset = offset - chunks.start();
|
||||
if let Some(chunk) = chunks.item()
|
||||
&& !chunk.text.is_char_boundary(chunk_offset)
|
||||
{
|
||||
panic!("byte index {} is not a char boundary", offset);
|
||||
}
|
||||
Self {
|
||||
chunks,
|
||||
range,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue