zed/crates/rope
Ben Brandt e5ff5550e4
Fix UTF-8 boundary crashes in syntax parsing (#65273)
Tree-sitter input callbacks receive byte offsets, which can fall inside
a UTF-8 character. Both language parser entry points previously sought
to that offset, sliced the rope chunk as `str`, and only then converted
it to bytes. This could panic while reparsing after an agent edit.

- Add `Chunks::peek_bytes` and use it in both parser callbacks,
preserving the exact requested offset without allocating or rounding to
a character boundary.
- Share the chunk slice-range computation with string and bitmap peeks,
preserving their existing UTF-8 requirements. Document that constructing
a `Chunks` cursor still requires an aligned initial offset.
- Use `Rope::bytes_in_range` for query text providers and add a
query-predicate regression for error nodes starting inside multibyte
characters.
- Add parser regressions for two-, three-, and four-byte characters and
nonzero syntax-layer origins; compare results with parsing contiguous
bytes.
- Exercise forward/reverse seeks across rope chunks, bounded ranges
starting or ending inside characters, and EOF/empty input.

Release Notes:

- Fixed a crash when syntax parsing requested bytes inside a multibyte
character.
2026-10-07 11:03:59 +00:00
..
benches gpui: Add bench_metrics for multi-metric Criterion benchmarks (#64753) 2026-09-27 17:37:29 +00:00
src Fix UTF-8 boundary crashes in syntax parsing (#65273) 2026-10-07 11:03:59 +00:00
Cargo.toml Reduce the dependency footprint (#65176) 2026-10-05 12:44:26 +00:00
LICENSE-GPL