# Avoid panics when normalizing completion label with invalid ranges \(\#23712\) · gitcafe/zed

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

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

Visibility: public

Requested revision: 5bde053b0d1a1a8be9dc89fc68bc4c63404eab77

Requested commit: 5bde053b0d1a1a8be9dc89fc68bc4c63404eab77

Commit: 5bde053b0d1a1a8be9dc89fc68bc4c63404eab77

Tree: 2c30d3540d32c8d2cbed399bc89786ecae69ad1d

Author: Kirill Bulatov

Committer: GitHub

## Message

````
Avoid panics when normalizing completion label with invalid ranges (#23712)

Dev builds show panics related to completion label normalization

<details>
<summary>Panic</summary>

```
index out of bounds: the len is 103 but the index is 103
zed::reliability::init_panic_hook::{{closure}}::h78130eff43c84f6f+110375521
std::panicking::rust_panic_with_hook::hfe205f6954b2c97b+87457752
std::panicking::begin_panic_handler::{{closure}}::h6cb44b3a50f28c44+87456967
std::sys::backtrace::__rust_end_short_backtrace::hf1c1f2a92799bb0e+87449337
rust_begin_unwind+87456084
core::panicking::panic_fmt::h3d8fc78294164da7+7033011
core::panicking::panic_bounds_check::h9397cb495d89a72d+7033511
project::lsp_store::ensure_uniform_list_compatible_label::haf80316ce11edd67+72663592
project::lsp_store::populate_labels_for_completions::{{closure}}::hc93c3c540ef7d2d6+72642960
project::lsp_store::LspStore::completions::{{closure}}::{{closure}}::hb4b5432e24432ca8+72336627
async_task::raw::RawTask<F,T,S,M>::run::hf444c3dc07dd583b+68504803
<gpui::platform::linux::wayland::client::WaylandClient as gpui::platform::linux::platform::LinuxClient>::run::hbf5a316eb781a10d+50646579
gpui::platform::linux::platform::<impl gpui::platform::Platform for P>::run::hc85518d4552fc4cd+50496669
gpui::app::App::run::hca4e2eaf984ca6f6+109905269
zed::main::h849467ac1a6d32c9+110413414
std::sys::backtrace::__rust_begin_short_backtrace::h81b5ee155a7cf505+110835475
std::rt::lang_start::{{closure}}::h48a83f884cfb6865+110834761
std::rt::lang_start_internal::h5e7c81cecd7f0954+87382485
main+110425932
__libc_start_call_main+22789462491720
__libc_start_main_alias_1+22789462491915
_start+10436606
```
</details>

This can only happen when either `label.runs` or `label.filter_range`
has a range that's larger than the label text, which is an error.
Instead of panicking, log such errors and fall back to last index (which
is not really helpful, but still).

Release Notes:

- N/A
````

## Parents

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

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