text: Assert text anchor offset validity on construction (#38441)

Attempt to aid debugging some utf8 indexing issues

Release Notes:

- N/A

Co-authored-by: Mikayla Maki <mikayla@zed.dev>
This commit is contained in:
Lukas Wirth
2025-09-22 11:20:46 +00:00
committed by GitHub
co-authored by Mikayla Maki
parent 79620454d0
commit a2c71d3d20
5 changed files with 195 additions and 6 deletions
@@ -29,7 +29,9 @@ pub fn refresh_matching_bracket_highlights(
if (editor.cursor_shape == CursorShape::Block || editor.cursor_shape == CursorShape::Hollow)
&& head < snapshot.buffer_snapshot.len()
{
tail += 1;
if let Some(tail_ch) = snapshot.buffer_snapshot.chars_at(tail).next() {
tail += tail_ch.len_utf8();
}
}
if let Some((opening_range, closing_range)) = snapshot