# ui: Don't panic on invalid highlight indices in \`HighlightedLabel\` \(\#57291\) · gitcafe/zed

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

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

Visibility: public

Requested revision: 7f7c21536e080a24861289aabccd99d78808a84e

Requested commit: 7f7c21536e080a24861289aabccd99d78808a84e

Commit: 7f7c21536e080a24861289aabccd99d78808a84e

Tree: 252bedbcb044157b8a5a430d1d8111096f3985bd

Author: Oleksiy Syvokon

Committer: GitHub

## Message

```
ui: Don't panic on invalid highlight indices in `HighlightedLabel` (#57291)

HighlightedLabel would crash the application if any provided highlight
index was invalid. In theory, this should never happen. In practice,
this can happen due to race conditions at call sites.

After this change, we only panic in debug builds. In release builds, we
log an error and return a label with no highlights. The error message
includes the call site so that it's easier to fix the root cause.

Related to #57290

Part of FR-11.

Release Notes:

- N/A
```

## Parents

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

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