From 9446e573e977d9064acddc461b16b486508c3f29 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Fri, 19 Jan 2024 10:26:39 +0100 Subject: [PATCH] Reuse layout for view's element when it wasn't cached --- crates/gpui/src/view.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/crates/gpui/src/view.rs b/crates/gpui/src/view.rs index e485aa3e57..ede1bd8b7f 100644 --- a/crates/gpui/src/view.rs +++ b/crates/gpui/src/view.rs @@ -321,8 +321,12 @@ impl Element for AnyView { } } - let mut element = (self.request_layout)(self, cx).1; - element.draw(bounds.origin, bounds.size.into(), cx); + if let Some(mut element) = state.element.take() { + element.paint(cx); + } else { + let mut element = (self.request_layout)(self, cx).1; + element.draw(bounds.origin, bounds.size.into(), cx); + } state.cache_key = Some(ViewCacheKey { bounds,