From 16c4fd4fc563eeedc645a50931129908bc3bfb07 Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Fri, 5 Sep 2025 13:19:57 +0200 Subject: [PATCH] gpui: move Option -> Result conversion out of closure in App::update_window_id (#37624) Doesn't fix anything, but it seems that we do not need to assert and convert into an error until after the closure run to completion, especially since this is the only error we throw. Release Notes: - N/A --- crates/gpui/src/app.rs | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/crates/gpui/src/app.rs b/crates/gpui/src/app.rs index 69d5c0ee4375443ad42a7b25a64a138406ac95a2..8b0b404d1dffbf8a27de1f29437ce9cc2ba63f0f 100644 --- a/crates/gpui/src/app.rs +++ b/crates/gpui/src/app.rs @@ -1358,12 +1358,7 @@ impl App { F: FnOnce(AnyView, &mut Window, &mut App) -> T, { self.update(|cx| { - let mut window = cx - .windows - .get_mut(id) - .context("window not found")? - .take() - .context("window not found")?; + let mut window = cx.windows.get_mut(id)?.take()?; let root_view = window.root.clone().unwrap(); @@ -1380,15 +1375,14 @@ impl App { true }); } else { - cx.windows - .get_mut(id) - .context("window not found")? - .replace(window); + cx.windows.get_mut(id)?.replace(window); } - Ok(result) + Some(result) }) + .context("window not found") } + /// Creates an `AsyncApp`, which can be cloned and has a static lifetime /// so it can be held across `await` points. pub fn to_async(&self) -> AsyncApp {