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

@ -10,10 +10,7 @@ use gpui::{
use itertools::Itertools;
use picker::{Picker, PickerDelegate, highlighted_match_with_paths::HighlightedMatch};
use project::{TaskSourceKind, task_store::TaskStore};
use task::{
DebugRequest, DebugTaskDefinition, ResolvedTask, RevealTarget, TaskContext, TaskModal,
TaskTemplate, TaskType,
};
use task::{DebugScenario, ResolvedTask, RevealTarget, TaskContext, TaskModal, TaskTemplate};
use ui::{
ActiveTheme, Button, ButtonCommon, ButtonSize, Clickable, Color, FluentBuilder as _, Icon,
IconButton, IconButtonShape, IconName, IconSize, IntoElement, KeyBinding, Label, LabelSize,
@ -187,7 +184,7 @@ impl Render for TasksModal {
}
pub struct ShowAttachModal {
pub debug_config: DebugTaskDefinition,
pub debug_config: DebugScenario,
}
impl EventEmitter<DismissEvent> for TasksModal {}
@ -354,48 +351,20 @@ impl PickerDelegate for TasksModalDelegate {
reveal_target: Some(reveal_target),
}) = &self.task_overrides
{
if let Some(resolved_task) = &mut task.resolved {
resolved_task.reveal_target = *reveal_target;
}
task.resolved.reveal_target = *reveal_target;
}
match task.task_type() {
TaskType::Debug(_) => {
let Some(config) = task.resolved_debug_adapter_config() else {
return;
};
let config = config.definition;
match &config.request {
DebugRequest::Attach(attach_config) if attach_config.process_id.is_none() => {
cx.emit(ShowAttachModal {
debug_config: config.clone(),
});
return;
}
_ => {
self.workspace
.update(cx, |workspace, cx| {
workspace.schedule_debug_task(task, window, cx);
})
.ok();
}
}
}
TaskType::Script => {
self.workspace
.update(cx, |workspace, cx| {
workspace.schedule_resolved_task(
task_source_kind,
task,
omit_history_entry,
window,
cx,
);
})
.ok();
}
};
self.workspace
.update(cx, |workspace, cx| {
workspace.schedule_resolved_task(
task_source_kind,
task,
omit_history_entry,
window,
cx,
);
})
.ok();
cx.emit(DismissEvent);
}
@ -422,16 +391,14 @@ impl PickerDelegate for TasksModalDelegate {
} else {
String::new()
};
if let Some(resolved) = resolved_task.resolved.as_ref() {
if resolved.command_label != display_label
&& resolved.command_label != resolved_task.resolved_label
{
if !tooltip_label_text.trim().is_empty() {
tooltip_label_text.push('\n');
}
tooltip_label_text.push_str(&resolved.command_label);
if resolved_task.resolved.command_label != resolved_task.resolved_label {
if !tooltip_label_text.trim().is_empty() {
tooltip_label_text.push('\n');
}
tooltip_label_text.push_str(&resolved_task.resolved.command_label);
}
if template.tags.len() > 0 {
tooltip_label_text.push('\n');
tooltip_label_text.push_str(
@ -553,7 +520,7 @@ impl PickerDelegate for TasksModalDelegate {
let task_index = self.matches.get(self.selected_index())?.candidate_id;
let tasks = self.candidates.as_ref()?;
let (_, task) = tasks.get(task_index)?;
Some(task.resolved.as_ref()?.command_label.clone())
Some(task.resolved.command_label.clone())
}
fn confirm_input(
@ -570,26 +537,17 @@ impl PickerDelegate for TasksModalDelegate {
reveal_target: Some(reveal_target),
}) = self.task_overrides
{
if let Some(resolved_task) = &mut task.resolved {
resolved_task.reveal_target = reveal_target;
}
task.resolved.reveal_target = reveal_target;
}
self.workspace
.update(cx, |workspace, cx| {
match task.task_type() {
TaskType::Script => workspace.schedule_resolved_task(
task_source_kind,
task,
omit_history_entry,
window,
cx,
),
// todo(debugger): Should create a schedule_resolved_debug_task function
// This would allow users to access to debug history and other issues
TaskType::Debug(_) => {
workspace.schedule_debug_task(task, window, cx);
}
};
workspace.schedule_resolved_task(
task_source_kind,
task,
omit_history_entry,
window,
cx,
)
})
.ok();
cx.emit(DismissEvent);
@ -716,10 +674,7 @@ fn string_match_candidates<'a>(
candidates
.into_iter()
.enumerate()
.filter(|(_, (_, candidate))| match candidate.task_type() {
TaskType::Script => task_modal_type == TaskModal::ScriptModal,
TaskType::Debug(_) => task_modal_type == TaskModal::DebugModal,
})
.filter(|(_, (_, _))| task_modal_type == TaskModal::ScriptModal)
.map(|(index, (_, candidate))| StringMatchCandidate::new(index, candidate.display_label()))
.collect()
}

View file

@ -65,13 +65,13 @@ pub fn init(cx: &mut App) {
})
.detach()
} else {
if let Some(resolved) = last_scheduled_task.resolved.as_mut() {
if let Some(allow_concurrent_runs) = action.allow_concurrent_runs {
resolved.allow_concurrent_runs = allow_concurrent_runs;
}
if let Some(use_new_terminal) = action.use_new_terminal {
resolved.use_new_terminal = use_new_terminal;
}
let resolved = &mut last_scheduled_task.resolved;
if let Some(allow_concurrent_runs) = action.allow_concurrent_runs {
resolved.allow_concurrent_runs = allow_concurrent_runs;
}
if let Some(use_new_terminal) = action.use_new_terminal {
resolved.use_new_terminal = use_new_terminal;
}
workspace.schedule_resolved_task(