gpui: Fix new window cascade positioning (#44358)
Jake Go
created 3 weeks ago
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
Change summary
crates/workspace/src/workspace.rs | 20 +++++++++-----------
1 file changed, 9 insertions(+), 11 deletions(-)
Detailed changes
@@ -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