Fix detach (#32506)
Release Notes: - debugger: Fix detach to not terminate debuggee (and only be available when detaching makes sense)
This commit is contained in:
parent
84eca53319
commit
1e1bc7c373
3 changed files with 53 additions and 22 deletions
|
@ -542,6 +542,8 @@ impl DebugPanel {
|
||||||
project::debugger::session::ThreadStatus::Exited,
|
project::debugger::session::ThreadStatus::Exited,
|
||||||
);
|
);
|
||||||
let capabilities = running_state.read(cx).capabilities(cx);
|
let capabilities = running_state.read(cx).capabilities(cx);
|
||||||
|
let supports_detach =
|
||||||
|
running_state.read(cx).session().read(cx).is_attached();
|
||||||
this.map(|this| {
|
this.map(|this| {
|
||||||
if thread_status == ThreadStatus::Running {
|
if thread_status == ThreadStatus::Running {
|
||||||
this.child(
|
this.child(
|
||||||
|
@ -730,27 +732,39 @@ impl DebugPanel {
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.child(
|
.when(
|
||||||
IconButton::new("debug-disconnect", IconName::DebugDetach)
|
supports_detach,
|
||||||
.icon_size(IconSize::XSmall)
|
|div| {
|
||||||
.on_click(window.listener_for(
|
div.child(
|
||||||
&running_state,
|
IconButton::new(
|
||||||
|this, _, _, cx| {
|
"debug-disconnect",
|
||||||
this.detach_client(cx);
|
IconName::DebugDetach,
|
||||||
},
|
)
|
||||||
))
|
.disabled(
|
||||||
.tooltip({
|
thread_status != ThreadStatus::Stopped
|
||||||
let focus_handle = focus_handle.clone();
|
&& thread_status != ThreadStatus::Running,
|
||||||
move |window, cx| {
|
)
|
||||||
Tooltip::for_action_in(
|
.icon_size(IconSize::XSmall)
|
||||||
"Detach",
|
.on_click(window.listener_for(
|
||||||
&Detach,
|
&running_state,
|
||||||
&focus_handle,
|
|this, _, _, cx| {
|
||||||
window,
|
this.detach_client(cx);
|
||||||
cx,
|
},
|
||||||
)
|
))
|
||||||
}
|
.tooltip({
|
||||||
}),
|
let focus_handle = focus_handle.clone();
|
||||||
|
move |window, cx| {
|
||||||
|
Tooltip::for_action_in(
|
||||||
|
"Detach",
|
||||||
|
&Detach,
|
||||||
|
&focus_handle,
|
||||||
|
window,
|
||||||
|
cx,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
},
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|
|
@ -113,6 +113,7 @@ pub fn init(cx: &mut App) {
|
||||||
let caps = running_state.capabilities(cx);
|
let caps = running_state.capabilities(cx);
|
||||||
let supports_restart = caps.supports_restart_request.unwrap_or_default();
|
let supports_restart = caps.supports_restart_request.unwrap_or_default();
|
||||||
let supports_step_back = caps.supports_step_back.unwrap_or_default();
|
let supports_step_back = caps.supports_step_back.unwrap_or_default();
|
||||||
|
let supports_detach = running_state.session().read(cx).is_attached();
|
||||||
let status = running_state.thread_status(cx);
|
let status = running_state.thread_status(cx);
|
||||||
|
|
||||||
let active_item = active_item.downgrade();
|
let active_item = active_item.downgrade();
|
||||||
|
@ -195,6 +196,14 @@ pub fn init(cx: &mut App) {
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
})
|
})
|
||||||
|
.when(supports_detach, |div| {
|
||||||
|
let active_item = active_item.clone();
|
||||||
|
div.on_action(move |_: &Detach, _, cx| {
|
||||||
|
active_item
|
||||||
|
.update(cx, |item, cx| item.detach_client(cx))
|
||||||
|
.ok();
|
||||||
|
})
|
||||||
|
})
|
||||||
.when(supports_restart, |div| {
|
.when(supports_restart, |div| {
|
||||||
let active_item = active_item.clone();
|
let active_item = active_item.clone();
|
||||||
div.on_action(move |_: &Restart, _, cx| {
|
div.on_action(move |_: &Restart, _, cx| {
|
||||||
|
|
|
@ -26,6 +26,7 @@ use dap::{
|
||||||
use dap::{
|
use dap::{
|
||||||
ExceptionBreakpointsFilter, ExceptionFilterOptions, OutputEvent, OutputEventCategory,
|
ExceptionBreakpointsFilter, ExceptionFilterOptions, OutputEvent, OutputEventCategory,
|
||||||
RunInTerminalRequestArguments, StackFramePresentationHint, StartDebuggingRequestArguments,
|
RunInTerminalRequestArguments, StackFramePresentationHint, StartDebuggingRequestArguments,
|
||||||
|
StartDebuggingRequestArgumentsRequest,
|
||||||
};
|
};
|
||||||
use futures::SinkExt;
|
use futures::SinkExt;
|
||||||
use futures::channel::{mpsc, oneshot};
|
use futures::channel::{mpsc, oneshot};
|
||||||
|
@ -2217,10 +2218,17 @@ impl Session {
|
||||||
self.locations.get(&reference).cloned()
|
self.locations.get(&reference).cloned()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn is_attached(&self) -> bool {
|
||||||
|
let Mode::Running(local_mode) = &self.mode else {
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
local_mode.binary.request_args.request == StartDebuggingRequestArgumentsRequest::Attach
|
||||||
|
}
|
||||||
|
|
||||||
pub fn disconnect_client(&mut self, cx: &mut Context<Self>) {
|
pub fn disconnect_client(&mut self, cx: &mut Context<Self>) {
|
||||||
let command = DisconnectCommand {
|
let command = DisconnectCommand {
|
||||||
restart: Some(false),
|
restart: Some(false),
|
||||||
terminate_debuggee: Some(true),
|
terminate_debuggee: Some(false),
|
||||||
suspend_debuggee: Some(false),
|
suspend_debuggee: Some(false),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue