# rope: Fix an unintentional panic \(\#47019\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/1ca52793ff9ccca80046688111cacc3e8d3588d4)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 1ca52793ff9ccca80046688111cacc3e8d3588d4

Requested commit: 1ca52793ff9ccca80046688111cacc3e8d3588d4

Commit: 1ca52793ff9ccca80046688111cacc3e8d3588d4

Tree: f6e53e93273fe0a08d8aac821ee7fabdb6e608d6

Author: Marco Mihai Condrache

Committer: GitHub

## Message

```
rope: Fix an unintentional panic (#47019)

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>
```

## Parents

- [164e37e41d48bb92a994eb3778d36d9285a6a465](https://git.cafe/gitcafe/zed/commit/164e37e41d48bb92a994eb3778d36d9285a6a465?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/1ca52793ff9ccca80046688111cacc3e8d3588d4?format=markdown)
