From ae25baad023f01a8b4a84b8b0ea35e58a804536e Mon Sep 17 00:00:00 2001 From: ozer <109994179+ddoemonn@users.noreply.github.com> Date: Thu, 16 Oct 2025 17:12:58 +0300 Subject: [PATCH] settings_ui: Fix settings popup process alive (#39790) Closes #39786 Release Notes: - Fixed: Settings popup no longer keeps the process alive when closing Zed on Windows --------- Co-authored-by: Anthony Co-authored-by: Joseph T. Lyons --- crates/settings_ui/src/settings_ui.rs | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/crates/settings_ui/src/settings_ui.rs b/crates/settings_ui/src/settings_ui.rs index 98555f0347b078d757e5acc53b7ddf269de2d7a8..7c79a3719f829ccda6c162b1fd13024a4b0e69b2 100644 --- a/crates/settings_ui/src/settings_ui.rs +++ b/crates/settings_ui/src/settings_ui.rs @@ -455,8 +455,9 @@ pub fn open_settings_editor( if let Some(existing_window) = existing_window { existing_window - .update(cx, |settings_window, window, _| { + .update(cx, |settings_window, window, cx| { settings_window.original_window = Some(workspace_handle); + settings_window.observe_last_window_close(cx); window.activate_window(); }) .ok(); @@ -1005,6 +1006,7 @@ impl SettingsWindow { let mut this = Self { title_bar, original_window, + worktree_root_dirs: HashMap::default(), files: vec![], drop_down_file: None, @@ -1042,6 +1044,8 @@ impl SettingsWindow { list_state, }; + this.observe_last_window_close(cx); + this.fetch_files(window, cx); this.build_ui(window, cx); this.build_search_index(); @@ -1053,6 +1057,23 @@ impl SettingsWindow { this } + fn observe_last_window_close(&mut self, cx: &mut App) { + cx.on_window_closed(|cx| { + if let Some(existing_window) = cx + .windows() + .into_iter() + .find_map(|window| window.downcast::()) + && cx.windows().len() == 1 + { + cx.update_window(*existing_window, |_, window, _| { + window.remove_window(); + }) + .ok(); + } + }) + .detach(); + } + fn toggle_navbar_entry(&mut self, nav_entry_index: usize) { // We can only toggle root entries if !self.navbar_entries[nav_entry_index].is_root {