Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Reuse layout for view's element when it wasn't cached

Antonio Scandurra9446e573e977
diff --git a/crates/gpui/src/view.rs b/crates/gpui/src/view.rs
index e485aa3e575..ede1bd8b7fd 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,