From 68cf631cfcdb07fb7adfdd25d6ea87969f8d69a0 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Fri, 22 Dec 2023 14:39:16 +0100 Subject: [PATCH] Reveal item even if project panel was closed while active entry changed The project panel was actually working just fine, the problem was due to `UniformList` not re-hydrating the element state's scroll offset when being rendered again. --- crates/gpui2/src/elements/uniform_list.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/crates/gpui2/src/elements/uniform_list.rs b/crates/gpui2/src/elements/uniform_list.rs index c26cfe612141d9dc3442308012d780af7ab153c5..e38a37f90d20c8612069f13daaf94ccb06c1dc89 100644 --- a/crates/gpui2/src/elements/uniform_list.rs +++ b/crates/gpui2/src/elements/uniform_list.rs @@ -190,7 +190,15 @@ impl Element for UniformList { let shared_scroll_offset = element_state .interactive .scroll_offset - .get_or_insert_with(Rc::default) + .get_or_insert_with(|| { + if let Some(scroll_handle) = self.scroll_handle.as_ref() { + if let Some(scroll_handle) = scroll_handle.0.borrow().as_ref() { + return scroll_handle.scroll_offset.clone(); + } + } + + Rc::default() + }) .clone(); let item_height = self.measure_item(Some(padded_bounds.size.width), cx).height;