From 3efc6ef80020e9e4d86a4454568de2f2729829b1 Mon Sep 17 00:00:00 2001 From: Dustin Yost Date: Fri, 5 Jun 2026 11:18:09 -0400 Subject: [PATCH] fix gpui_window Window::zoom not restoring the window when already maximized (#33) --- crates/gpui_windows/src/window.rs | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/crates/gpui_windows/src/window.rs b/crates/gpui_windows/src/window.rs index b33d8702f2..8a0e395392 100644 --- a/crates/gpui_windows/src/window.rs +++ b/crates/gpui_windows/src/window.rs @@ -860,14 +860,23 @@ impl PlatformWindow for WindowsWindow { } fn zoom(&self) { - unsafe { - if IsWindowVisible(self.0.hwnd).as_bool() { - ShowWindowAsync(self.0.hwnd, SW_MAXIMIZE).ok().log_err(); - } else if let Some(mut status) = self.state.initial_placement.take() { - status.state = WindowOpenState::Maximized; - self.state.initial_placement.set(Some(status)); + let is_visible = unsafe { IsWindowVisible(self.0.hwnd).as_bool() }; + if !is_visible { + if let Some(mut status) = self.state.initial_placement.take() { + status.state = WindowOpenState::Maximized; + self.state.initial_placement.set(Some(status)); } + return; } + + let window_operation = if self.is_maximized() { + SW_RESTORE + } + else + { + SW_MAXIMIZE + }; + unsafe { ShowWindowAsync(self.0.hwnd, window_operation).ok().log_err(); } } fn toggle_fullscreen(&self) {