From 59632f8ab16298dc0f1d0519f6665fca60c9e772 Mon Sep 17 00:00:00 2001 From: "zed-zippy[bot]" <234243425+zed-zippy[bot]@users.noreply.github.com> Date: Thu, 19 Mar 2026 12:15:34 +0000 Subject: [PATCH] Fix the inability to click the highlight tree view (#51927) (cherry-pick to preview) (#51928) Cherry-pick of #51927 to preview ---- Before: https://github.com/user-attachments/assets/14de9b93-d1d0-4ac8-b51d-a0fe80543ca0 After: https://github.com/user-attachments/assets/ec27b342-5a3b-4f5d-b28a-0db4256518ef Release Notes: - Fixed highlight tree view usability Co-authored-by: Kirill Bulatov --- .../src/highlights_tree_view.rs | 28 +++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/crates/language_tools/src/highlights_tree_view.rs b/crates/language_tools/src/highlights_tree_view.rs index fb92e21ab33eb3b6a3cd498a6ffbdd764947ea9e..8a139958897c261816171c364b6d1f62ccb3b8c6 100644 --- a/crates/language_tools/src/highlights_tree_view.rs +++ b/crates/language_tools/src/highlights_tree_view.rs @@ -209,20 +209,32 @@ impl HighlightsTreeView { window: &mut Window, cx: &mut Context, ) { - let Some(editor) = active_item - .filter(|item| item.item_id() != cx.entity_id()) - .and_then(|item| item.downcast::()) - else { - self.clear(cx); - return; + let active_editor = match active_item { + Some(active_item) => { + if active_item.item_id() == cx.entity_id() { + return; + } else { + match active_item.downcast::() { + Some(active_editor) => active_editor, + None => { + self.clear(cx); + return; + } + } + } + } + None => { + self.clear(cx); + return; + } }; let is_different_editor = self .editor .as_ref() - .is_none_or(|state| state.editor != editor); + .is_none_or(|state| state.editor != active_editor); if is_different_editor { - self.set_editor(editor, window, cx); + self.set_editor(active_editor, window, cx); } }