From d7b99a5b12a18e4bad360a1745b882b3823773ed Mon Sep 17 00:00:00 2001 From: Jake Go Date: Mon, 8 Dec 2025 03:11:58 -0500 Subject: [PATCH] gpui: Fix new window cascade positioning (#44358) Closes [#44354](https://github.com/zed-industries/zed/discussions/44354) Release Notes: - Fixed new windows to properly cascade from the active window instead of opening at the exact same position --- crates/workspace/src/workspace.rs | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index c79159e3dcb282c9622d01f1ee6cea39a5fd0f03..43dd4bd701fdc8c0cf394043daf35d08d6c05328 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -1641,20 +1641,18 @@ impl Workspace { let (window_bounds, display) = if let Some(bounds) = window_bounds_override { (Some(WindowBounds::Windowed(bounds)), None) - } else { - let restorable_bounds = serialized_workspace - .as_ref() - .and_then(|workspace| Some((workspace.display?, workspace.window_bounds?))) - .or_else(|| { - let (display, window_bounds) = DB.last_window().log_err()?; - Some((display?, window_bounds?)) - }); - - if let Some((serialized_display, serialized_status)) = restorable_bounds { - (Some(serialized_status.0), Some(serialized_display)) + } else if let Some(workspace) = serialized_workspace.as_ref() { + // Reopening an existing workspace - restore its saved bounds + if let (Some(display), Some(bounds)) = + (workspace.display, workspace.window_bounds.as_ref()) + { + (Some(bounds.0), Some(display)) } else { (None, None) } + } else { + // New window - let GPUI's default_bounds() handle cascading + (None, None) }; // Use the serialized workspace to construct the new window