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
This commit is contained in:
Jakub Konka
2025-09-05 13:19:57 +02:00
committed by GitHub
parent ec58adca13
commit 16c4fd4fc5
+5 -11
View File
@@ -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 {