From 4e316c683bc31794833ce64a706b18319371f72f Mon Sep 17 00:00:00 2001 From: Ben Kunkle Date: Fri, 19 Sep 2025 14:07:02 -0500 Subject: [PATCH] macos: Fix panic when `NSWindow::screen` returns `nil` (#38524) Closes #ISSUE Release Notes: - mac: Fixed an issue where Zed would panic if the workspace window was previously off screen --- crates/gpui/src/platform/mac/window.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/crates/gpui/src/platform/mac/window.rs b/crates/gpui/src/platform/mac/window.rs index 1230a704062ba835bceb5db5d2ecf05b688e34df..e8b42c57b8239f53118487f51bd194178c3c21c0 100644 --- a/crates/gpui/src/platform/mac/window.rs +++ b/crates/gpui/src/platform/mac/window.rs @@ -513,10 +513,11 @@ impl MacWindowState { fn bounds(&self) -> Bounds { let mut window_frame = unsafe { NSWindow::frame(self.native_window) }; - let screen_frame = unsafe { - let screen = NSWindow::screen(self.native_window); - NSScreen::frame(screen) - }; + let screen = unsafe { NSWindow::screen(self.native_window) }; + if screen == nil { + return Bounds::new(point(px(0.), px(0.)), crate::DEFAULT_WINDOW_SIZE); + } + let screen_frame = unsafe { NSScreen::frame(screen) }; // Flip the y coordinate to be top-left origin window_frame.origin.y =