From 00c5b83384f63e8e8e1a2c3a3ea14de5967cb82a Mon Sep 17 00:00:00 2001 From: Remco Smits Date: Fri, 5 Jul 2024 16:50:43 +0200 Subject: [PATCH] Update handle terminated event to restart debugger --- crates/debugger_ui/src/debugger_panel.rs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/crates/debugger_ui/src/debugger_panel.rs b/crates/debugger_ui/src/debugger_panel.rs index 04def9935ad731..8b7a78561089ca 100644 --- a/crates/debugger_ui/src/debugger_panel.rs +++ b/crates/debugger_ui/src/debugger_panel.rs @@ -15,6 +15,7 @@ use gpui::{ use project::Project; use std::path::Path; use std::{collections::HashMap, sync::Arc}; +use task::DebugRequestType; use ui::{prelude::*, Tooltip}; use workspace::{ dock::{DockPosition, Panel, PanelEvent}, @@ -539,17 +540,28 @@ impl DebugPanel { event: &Option, cx: &mut ViewContext, ) { - let restart = event.as_ref().is_some_and(|e| e.restart.is_some()); + let restart_args = event.clone().and_then(|e| e.restart); let client = this.debug_client_by_id(*client_id, cx); cx.spawn(|_, _| async move { + let should_restart = restart_args.is_some(); + client .request::(DisconnectArguments { - restart: Some(restart), + restart: Some(should_restart), terminate_debuggee: None, suspend_debuggee: None, }) - .await + .await?; + + if should_restart { + match client.request_type() { + DebugRequestType::Launch => client.launch(restart_args).await, + DebugRequestType::Attach => client.attach(restart_args).await, + } + } else { + anyhow::Ok(()) + } }) .detach_and_log_err(cx); }