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.

Use AppContext::update when updating windows so we handle effects

Nathan Sobofc96676662f1
diff --git a/crates/gpui/src/app.rs b/crates/gpui/src/app.rs
index 8020147844d..8682e6c9dd6 100644
--- a/crates/gpui/src/app.rs
+++ b/crates/gpui/src/app.rs
@@ -2112,13 +2112,15 @@ impl BorrowWindowContext for AppContext {
where
F: FnOnce(&mut WindowContext) -> T,
{
- let mut window = self.windows.remove(&handle)?;
- let mut window_context = WindowContext::mutable(self, &mut window, handle);
- let result = f(&mut window_context);
- if !window_context.removed {
- self.windows.insert(handle, window);
- }
- Some(result)
+ self.update(|cx| {
+ let mut window = cx.windows.remove(&handle)?;
+ let mut window_context = WindowContext::mutable(cx, &mut window, handle);
+ let result = f(&mut window_context);
+ if !window_context.removed {
+ cx.windows.insert(handle, window);
+ }
+ Some(result)
+ })
}
fn update_window_optional<T, F>(&mut self, handle: AnyWindowHandle, f: F) -> Option<T>