Skip to content

Fix crash on non-ASCII thread titles in archive search#53114

Merged
rtfeldman merged 1 commit intomainfrom
fix-archive-highlight-panic
Apr 4, 2026
Merged

Fix crash on non-ASCII thread titles in archive search#53114
rtfeldman merged 1 commit intomainfrom
fix-archive-highlight-panic

Conversation

@rtfeldman
Copy link
Copy Markdown
Contributor

The archive view's fuzzy_match_positions used chars().enumerate() which produces character indices, not byte indices. When thread titles contain multi-byte UTF-8 characters (emoji, CJK, accented characters, etc.), these character indices don't correspond to valid byte boundaries, causing a panic in HighlightedLabel::new which asserts that highlight indices are valid UTF-8 boundaries.

The fix switches to char_indices() and eq_ignore_ascii_case() to produce correct byte positions, matching the approach already used by the sidebar's version of the same function.

Release Notes:

  • Fixed a crash when searching archived threads whose titles contain emoji or other non-ASCII characters.

The archive view's fuzzy_match_positions used chars().enumerate()
which produces character indices, not byte indices. When thread titles
contain multi-byte UTF-8 characters (emoji, CJK, etc.), these character
indices don't correspond to valid byte boundaries, causing a panic in
HighlightedLabel::new which asserts that highlight indices are valid
UTF-8 boundaries.

Switch to char_indices() and eq_ignore_ascii_case() to produce correct
byte positions, matching the approach used by the sidebar's version of
the same function.
@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Apr 4, 2026
@zed-community-bot zed-community-bot Bot added the staff Pull requests authored by a current member of Zed staff label Apr 4, 2026
@rtfeldman rtfeldman marked this pull request as ready for review April 4, 2026 01:54
@rtfeldman rtfeldman merged commit 68452a3 into main Apr 4, 2026
42 checks passed
@rtfeldman rtfeldman deleted the fix-archive-highlight-panic branch April 4, 2026 01:55
@bennetbo
Copy link
Copy Markdown
Member

bennetbo commented Apr 4, 2026

@zed-zippy approved

@zed-zippy zed-zippy Bot added the PR state:needs review Used to label PRs that are in need of a post-merge approval label Apr 6, 2026
@MrSubidubi MrSubidubi removed the PR state:needs review Used to label PRs that are in need of a post-merge approval label Apr 7, 2026
piper-of-dawn pushed a commit to piper-of-dawn/zed that referenced this pull request Apr 25, 2026
…s#53114)

The archive view's `fuzzy_match_positions` used `chars().enumerate()`
which produces **character indices**, not **byte indices**. When thread
titles contain multi-byte UTF-8 characters (emoji, CJK, accented
characters, etc.), these character indices don't correspond to valid
byte boundaries, causing a panic in `HighlightedLabel::new` which
asserts that highlight indices are valid UTF-8 boundaries.

The fix switches to `char_indices()` and `eq_ignore_ascii_case()` to
produce correct byte positions, matching the approach already used by
the sidebar's version of the same function.

Release Notes:

- Fixed a crash when searching archived threads whose titles contain
emoji or other non-ASCII characters.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement staff Pull requests authored by a current member of Zed staff

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants