debugger/tasks: Remove TaskType enum (#29208)

Closes #ISSUE

Release Notes:

- N/A

---------

Co-authored-by: Cole Miller <m@cole-miller.net>
Co-authored-by: Anthony Eid <hello@anthonyeid.me>
Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
Co-authored-by: Anthony <anthony@zed.dev>
Co-authored-by: Conrad <conrad@zed.dev>
This commit is contained in:
Piotr Osiewicz 2025-04-26 01:44:56 +02:00 committed by GitHub
parent 053fafa90e
commit 67615b968b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
53 changed files with 1272 additions and 1114 deletions

View file

@ -1,4 +1,5 @@
use dap::DebugRequest;
use dap::adapters::DebugTaskDefinition;
use fuzzy::{StringMatch, StringMatchCandidate};
use gpui::{DismissEvent, Entity, EventEmitter, Focusable, Render};
use gpui::{Subscription, WeakEntity};
@ -24,20 +25,20 @@ pub(crate) struct AttachModalDelegate {
selected_index: usize,
matches: Vec<StringMatch>,
placeholder_text: Arc<str>,
pub(crate) definition: DebugTaskDefinition,
workspace: WeakEntity<Workspace>,
pub(crate) debug_config: task::DebugTaskDefinition,
candidates: Arc<[Candidate]>,
}
impl AttachModalDelegate {
fn new(
workspace: Entity<Workspace>,
debug_config: task::DebugTaskDefinition,
definition: DebugTaskDefinition,
candidates: Arc<[Candidate]>,
) -> Self {
Self {
workspace: workspace.downgrade(),
debug_config,
definition,
candidates,
selected_index: 0,
matches: Vec::default(),
@ -53,8 +54,8 @@ pub struct AttachModal {
impl AttachModal {
pub fn new(
definition: DebugTaskDefinition,
workspace: Entity<Workspace>,
debug_config: task::DebugTaskDefinition,
modal: bool,
window: &mut Window,
cx: &mut Context<Self>,
@ -77,12 +78,12 @@ impl AttachModal {
.collect();
processes.sort_by_key(|k| k.name.clone());
let processes = processes.into_iter().collect();
Self::with_processes(workspace, debug_config, processes, modal, window, cx)
Self::with_processes(workspace, definition, processes, modal, window, cx)
}
pub(super) fn with_processes(
workspace: Entity<Workspace>,
debug_config: task::DebugTaskDefinition,
definition: DebugTaskDefinition,
processes: Arc<[Candidate]>,
modal: bool,
window: &mut Window,
@ -90,7 +91,7 @@ impl AttachModal {
) -> Self {
let picker = cx.new(|cx| {
Picker::uniform_list(
AttachModalDelegate::new(workspace, debug_config, processes),
AttachModalDelegate::new(workspace, definition, processes),
window,
cx,
)
@ -217,7 +218,7 @@ impl PickerDelegate for AttachModalDelegate {
return cx.emit(DismissEvent);
};
match &mut self.debug_config.request {
match &mut self.definition.request {
DebugRequest::Attach(config) => {
config.process_id = Some(candidate.pid);
}
@ -227,7 +228,8 @@ impl PickerDelegate for AttachModalDelegate {
}
}
let definition = self.debug_config.clone();
let scenario = self.definition.to_scenario();
let panel = self
.workspace
.update(cx, |workspace, cx| workspace.panel::<DebugPanel>(cx))
@ -235,9 +237,10 @@ impl PickerDelegate for AttachModalDelegate {
.flatten();
if let Some(panel) = panel {
panel.update(cx, |panel, cx| {
panel.start_session(definition, window, cx);
panel.start_session(scenario, Default::default(), None, window, cx);
});
}
cx.emit(DismissEvent);
}