
Reworks the way tasks are stored, accessed and synchronized in the `project`. Now both collab and ssh remote projects use the same TaskStorage kind to get the task context from the remote host, and worktree task templates are synchronized along with other worktree settings. Release Notes: - Adds ssh support to tasks, improves collab-remote projects' tasks sync
50 lines
1.5 KiB
Rust
50 lines
1.5 KiB
Rust
use project::TaskSourceKind;
|
|
use task::{ResolvedTask, TaskContext, TaskTemplate};
|
|
use ui::ViewContext;
|
|
|
|
use crate::Workspace;
|
|
|
|
pub fn schedule_task(
|
|
workspace: &Workspace,
|
|
task_source_kind: TaskSourceKind,
|
|
task_to_resolve: &TaskTemplate,
|
|
task_cx: &TaskContext,
|
|
omit_history: bool,
|
|
cx: &mut ViewContext<'_, Workspace>,
|
|
) {
|
|
if let Some(spawn_in_terminal) =
|
|
task_to_resolve.resolve_task(&task_source_kind.to_id_base(), task_cx)
|
|
{
|
|
schedule_resolved_task(
|
|
workspace,
|
|
task_source_kind,
|
|
spawn_in_terminal,
|
|
omit_history,
|
|
cx,
|
|
);
|
|
}
|
|
}
|
|
|
|
pub fn schedule_resolved_task(
|
|
workspace: &Workspace,
|
|
task_source_kind: TaskSourceKind,
|
|
mut resolved_task: ResolvedTask,
|
|
omit_history: bool,
|
|
cx: &mut ViewContext<'_, Workspace>,
|
|
) {
|
|
if let Some(spawn_in_terminal) = resolved_task.resolved.take() {
|
|
if !omit_history {
|
|
resolved_task.resolved = Some(spawn_in_terminal.clone());
|
|
workspace.project().update(cx, |project, cx| {
|
|
if let Some(task_inventory) =
|
|
project.task_store().read(cx).task_inventory().cloned()
|
|
{
|
|
task_inventory.update(cx, |inventory, _| {
|
|
inventory.task_scheduled(task_source_kind, resolved_task);
|
|
})
|
|
}
|
|
});
|
|
}
|
|
cx.emit(crate::Event::SpawnTask(Box::new(spawn_in_terminal)));
|
|
}
|
|
}
|