Add the ability for tasks to target the center pane (#22004)
Closes #20060 Closes #20720 Closes #19873 Closes #9445 Release Notes: - Fixed a bug where tasks would be spawned with their working directory set to a file in some cases - Added the ability to spawn tasks in the center pane, when spawning from a keybinding: ```json5 [ { // Assuming you have a task labeled "echo hello" "ctrl--": [ "task::Spawn", { "task_name": "echo hello", "target": "center" } ] } ] ```
This commit is contained in:
parent
85c3aec6e7
commit
4f96706161
18 changed files with 263 additions and 106 deletions
|
@ -18,11 +18,11 @@ pub use vscode_format::VsCodeTaskFile;
|
|||
|
||||
/// Task identifier, unique within the application.
|
||||
/// Based on it, task reruns and terminal tabs are managed.
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Deserialize)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Deserialize, Serialize)]
|
||||
pub struct TaskId(pub String);
|
||||
|
||||
/// Contains all information needed by Zed to spawn a new terminal tab for the given task.
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct SpawnInTerminal {
|
||||
/// Id of the task to use when determining task tab affinity.
|
||||
pub id: TaskId,
|
||||
|
@ -57,6 +57,15 @@ pub struct SpawnInTerminal {
|
|||
pub show_command: bool,
|
||||
}
|
||||
|
||||
/// An action for spawning a specific task
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct NewCenterTask {
|
||||
/// The specification of the task to spawn.
|
||||
pub action: SpawnInTerminal,
|
||||
}
|
||||
|
||||
gpui::impl_actions!(tasks, [NewCenterTask]);
|
||||
|
||||
/// A final form of the [`TaskTemplate`], that got resolved with a particualar [`TaskContext`] and now is ready to spawn the actual task.
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct ResolvedTask {
|
||||
|
@ -75,6 +84,9 @@ pub struct ResolvedTask {
|
|||
/// Further actions that need to take place after the resolved task is spawned,
|
||||
/// with all task variables resolved.
|
||||
pub resolved: Option<SpawnInTerminal>,
|
||||
|
||||
/// where to sawn the task in the UI, either in the terminal panel or in the center pane
|
||||
pub target: zed_actions::TaskSpawnTarget,
|
||||
}
|
||||
|
||||
impl ResolvedTask {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue