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
This commit is contained in:
Ben Kunkle
2025-09-19 13:07:02 -06:00
committed by GitHub
parent 1afbfcb832
commit 4e316c683b
+5 -4
View File
@@ -513,10 +513,11 @@ impl MacWindowState {
fn bounds(&self) -> Bounds<Pixels> {
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 =