Move task centering code closer to user input (#22082)
Follow-up of https://github.com/zed-industries/zed/pull/22004 * Reuse center terminals for tasks, when requested * Extend task templates with `RevealTarget`, moving it from `TaskSpawnTarget` into the core library * Use `reveal_target` instead of `target` to avoid misinterpretations in the task template context * Do not expose `SpawnInTerminal` to user interface, avoid it implementing `Serialize` and `Deserialize` * Remove `NewCenterTask` action, extending `task::Spawn` interface instead * Do not require any extra unrelated parameters during task resolution, instead, use task overrides on the resolved tasks on the modal side * Add keybindings for opening the task modal in the `RevealTarget::Center` mode Release Notes: - N/A
This commit is contained in:
parent
ea012075fc
commit
bc113e4b51
17 changed files with 356 additions and 285 deletions
|
@ -184,7 +184,7 @@ impl Inventory {
|
|||
let id_base = kind.to_id_base();
|
||||
Some((
|
||||
kind,
|
||||
task.resolve_task(&id_base, Default::default(), task_context)?,
|
||||
task.resolve_task(&id_base, task_context)?,
|
||||
not_used_score,
|
||||
))
|
||||
})
|
||||
|
@ -378,7 +378,7 @@ mod test_inventory {
|
|||
|
||||
use crate::Inventory;
|
||||
|
||||
use super::{task_source_kind_preference, TaskSourceKind};
|
||||
use super::TaskSourceKind;
|
||||
|
||||
pub(super) fn task_template_names(
|
||||
inventory: &Model<Inventory>,
|
||||
|
@ -409,7 +409,7 @@ mod test_inventory {
|
|||
let id_base = task_source_kind.to_id_base();
|
||||
inventory.task_scheduled(
|
||||
task_source_kind.clone(),
|
||||
task.resolve_task(&id_base, Default::default(), &TaskContext::default())
|
||||
task.resolve_task(&id_base, &TaskContext::default())
|
||||
.unwrap_or_else(|| panic!("Failed to resolve task with name {task_name}")),
|
||||
);
|
||||
});
|
||||
|
@ -427,31 +427,12 @@ mod test_inventory {
|
|||
.into_iter()
|
||||
.filter_map(|(source_kind, task)| {
|
||||
let id_base = source_kind.to_id_base();
|
||||
Some((
|
||||
source_kind,
|
||||
task.resolve_task(&id_base, Default::default(), task_context)?,
|
||||
))
|
||||
Some((source_kind, task.resolve_task(&id_base, task_context)?))
|
||||
})
|
||||
.map(|(source_kind, resolved_task)| (source_kind, resolved_task.resolved_label))
|
||||
.collect()
|
||||
})
|
||||
}
|
||||
|
||||
pub(super) async fn list_tasks_sorted_by_last_used(
|
||||
inventory: &Model<Inventory>,
|
||||
worktree: Option<WorktreeId>,
|
||||
cx: &mut TestAppContext,
|
||||
) -> Vec<(TaskSourceKind, String)> {
|
||||
let (used, current) = inventory.update(cx, |inventory, cx| {
|
||||
inventory.used_and_current_resolved_tasks(worktree, None, &TaskContext::default(), cx)
|
||||
});
|
||||
let mut all = used;
|
||||
all.extend(current);
|
||||
all.into_iter()
|
||||
.map(|(source_kind, task)| (source_kind, task.resolved_label))
|
||||
.sorted_by_key(|(kind, label)| (task_source_kind_preference(kind), label.clone()))
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
|
||||
/// A context provided that tries to provide values for all non-custom [`VariableName`] variants for a currently opened file.
|
||||
|
@ -877,7 +858,7 @@ mod tests {
|
|||
TaskStore::init(None);
|
||||
}
|
||||
|
||||
pub(super) async fn resolved_task_names(
|
||||
async fn resolved_task_names(
|
||||
inventory: &Model<Inventory>,
|
||||
worktree: Option<WorktreeId>,
|
||||
cx: &mut TestAppContext,
|
||||
|
@ -905,4 +886,20 @@ mod tests {
|
|||
))
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
async fn list_tasks_sorted_by_last_used(
|
||||
inventory: &Model<Inventory>,
|
||||
worktree: Option<WorktreeId>,
|
||||
cx: &mut TestAppContext,
|
||||
) -> Vec<(TaskSourceKind, String)> {
|
||||
let (used, current) = inventory.update(cx, |inventory, cx| {
|
||||
inventory.used_and_current_resolved_tasks(worktree, None, &TaskContext::default(), cx)
|
||||
});
|
||||
let mut all = used;
|
||||
all.extend(current);
|
||||
all.into_iter()
|
||||
.map(|(source_kind, task)| (source_kind, task.resolved_label))
|
||||
.sorted_by_key(|(kind, label)| (task_source_kind_preference(kind), label.clone()))
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue