rope: Fix an unintentional panic (#47019) (cherry-pick to preview) (#47212)
zed-zippy[bot]
and
Marco Mihai Condrache
created
Cherry-pick of #47019 to preview
----
Avoids the panic in #46974
But should be solved by using `saturating_sub` on the `start_overshoot`
calculation, ref:
https://github.com/zed-industries/zed/pull/47046#issuecomment-3762855786
https://github.com/zed-industries/zed/blob/37715d5a50666baaa824eafec2131ee6d80f8e0b/crates/rope/src/chunk.rs#L403C5-L415C6
This function gets called with PANIC = false from `slice`. But if the
offset is outside the text, `log_err_char_boundary` will still panic,
because the first `if` doesn’t bail out early.
Release Notes:
- N/A
Signed-off-by: Marco Mihai Condrache
<52580954+marcocondrache@users.noreply.github.com>
Signed-off-by: Marco Mihai Condrache <52580954+marcocondrache@users.noreply.github.com>
Co-authored-by: Marco Mihai Condrache <52580954+marcocondrache@users.noreply.github.com>