mirror of
https://github.com/zed-industries/zed.git
synced 2026-04-18 07:47:53 +00:00
972731cb1a
When filtering themes with a query that matches nothing (e.g., "zzz"), `show_selected_theme` returned `None` and overwrote `selected_theme`. Clearing the filter then lost track of the previous selection and defaulted to index 0. The fix only updates `selected_theme` when `show_selected_theme` returns `Some`. Same change in both the theme selector and the icon theme selector. ## Context When `update_matches` runs a filter that yields zero results, `show_selected_theme` returns `None`. The old code unconditionally assigned that back to `selected_theme`, wiping out the previous selection. When the user clears the filter, the selector falls into the `query.is_empty() && selected_theme.is_none()` branch and resets to index 0 instead of restoring the original pick. ## Demo ### Before: https://github.com/user-attachments/assets/62b1531b-d059-4f30-b1f4-a830f2d13a09 ### After: https://github.com/user-attachments/assets/72348666-8dbb-4f35-9446-fa2618340b6c ## How to review The fix is the same one-line change in two files: 1. `crates/theme_selector/src/theme_selector.rs` — line 458 2. `crates/theme_selector/src/icon_theme_selector.rs` — line 272 The rest is test infrastructure: 3. `crates/theme/src/registry.rs` — `register_test_themes` / `register_test_icon_themes` helpers 4. Tests in both selector files covering the empty filter → clear filter flow ## Self-review checklist - [x] I've reviewed my own diff for quality, security, and reliability - [x] Unsafe blocks (if any) have justifying comments - [x] The content is consistent with the [UI/UX checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) - [x] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable ## Release notes - Fixed theme selector losing the selected theme after filtering with a query that matches nothing and then clearing the filter.