Small improvements of the task terminal spawn behavior (#9399)
* Add a `reveal: always|never` field in task definitions from tasks.json , allowing to customize task terminal behavior on spawn * Ensure reveal: always reveals the terminal even if the old task is already running Release Notes: - Added a `reveal: always|never` (`always` is a default) field in task definitions from tasks.json , allowing to customize task terminal behavior on spawn --------- Co-authored-by: Piotr Osiewicz <piotr@zed.dev>
This commit is contained in:
parent
276139f792
commit
dcdd1ece1c
6 changed files with 79 additions and 19 deletions
|
@ -6,6 +6,7 @@ pub mod static_source;
|
|||
|
||||
use collections::HashMap;
|
||||
use gpui::ModelContext;
|
||||
use static_source::RevealStrategy;
|
||||
use std::any::Any;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::sync::Arc;
|
||||
|
@ -34,6 +35,8 @@ pub struct SpawnInTerminal {
|
|||
pub use_new_terminal: bool,
|
||||
/// Whether to allow multiple instances of the same task to be run, or rather wait for the existing ones to finish.
|
||||
pub allow_concurrent_runs: bool,
|
||||
/// What to do with the terminal pane and tab, after the command was started.
|
||||
pub reveal: RevealStrategy,
|
||||
}
|
||||
|
||||
/// Keeps track of the file associated with a task and context of tasks execution (i.e. current file or current function)
|
||||
|
|
|
@ -2,7 +2,9 @@
|
|||
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::{SpawnInTerminal, Task, TaskContext, TaskId, TaskSource};
|
||||
use crate::{
|
||||
static_source::RevealStrategy, SpawnInTerminal, Task, TaskContext, TaskId, TaskSource,
|
||||
};
|
||||
use gpui::{AppContext, Context, Model};
|
||||
|
||||
/// A storage and source of tasks generated out of user command prompt inputs.
|
||||
|
@ -48,6 +50,7 @@ impl Task for OneshotTask {
|
|||
env,
|
||||
use_new_terminal: Default::default(),
|
||||
allow_concurrent_runs: Default::default(),
|
||||
reveal: RevealStrategy::default(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ impl Task for StaticTask {
|
|||
label: self.definition.label.clone(),
|
||||
command: self.definition.command.clone(),
|
||||
args: self.definition.args.clone(),
|
||||
reveal: self.definition.reveal,
|
||||
env: definition_env,
|
||||
})
|
||||
}
|
||||
|
@ -64,6 +65,7 @@ pub struct StaticSource {
|
|||
|
||||
/// Static task definition from the tasks config file.
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub(crate) struct Definition {
|
||||
/// Human readable name of the task to display in the UI.
|
||||
pub label: String,
|
||||
|
@ -84,6 +86,22 @@ pub(crate) struct Definition {
|
|||
/// Whether to allow multiple instances of the same task to be run, or rather wait for the existing ones to finish.
|
||||
#[serde(default)]
|
||||
pub allow_concurrent_runs: bool,
|
||||
/// What to do with the terminal pane and tab, after the command was started:
|
||||
/// * `always` — always show the terminal pane, add and focus the corresponding task's tab in it (default)
|
||||
/// * `never` — avoid changing current terminal pane focus, but still add/reuse the task's tab there
|
||||
#[serde(default)]
|
||||
pub reveal: RevealStrategy,
|
||||
}
|
||||
|
||||
/// What to do with the terminal pane and tab, after the command was started.
|
||||
#[derive(Default, Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum RevealStrategy {
|
||||
/// Always show the terminal pane, add and focus the corresponding task's tab in it.
|
||||
#[default]
|
||||
Always,
|
||||
/// Do not change terminal pane focus, but still add/reuse the task's tab there.
|
||||
Never,
|
||||
}
|
||||
|
||||
/// A group of Tasks defined in a JSON file.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue