Stricten Zed Task variable API (#10163)
Introduce `VariableName` enum to simplify Zed task templating management: now all the variables can be looked up statically and can be checked/modified in a centralized way: e.g. `ZED_` prefix is now added for all such custom vars. Release Notes: - N/A
This commit is contained in:
parent
ee1b1779f1
commit
1085642c88
10 changed files with 188 additions and 91 deletions
|
@ -42,23 +42,24 @@ pub fn tasks_for(tasks: TaskDefinitions, id_base: &str) -> Vec<Arc<dyn Task>> {
|
|||
}
|
||||
|
||||
impl Task for StaticTask {
|
||||
fn exec(&self, cx: TaskContext) -> Option<SpawnInTerminal> {
|
||||
fn prepare_exec(&self, cx: TaskContext) -> Option<SpawnInTerminal> {
|
||||
let TaskContext {
|
||||
cwd,
|
||||
task_variables,
|
||||
} = cx;
|
||||
let task_variables = task_variables.into_env_variables();
|
||||
let cwd = self
|
||||
.definition
|
||||
.cwd
|
||||
.clone()
|
||||
.and_then(|path| {
|
||||
subst::substitute(&path, &task_variables.0)
|
||||
subst::substitute(&path, &task_variables)
|
||||
.map(Into::into)
|
||||
.ok()
|
||||
})
|
||||
.or(cwd);
|
||||
let mut definition_env = self.definition.env.clone();
|
||||
definition_env.extend(task_variables.0);
|
||||
definition_env.extend(task_variables);
|
||||
Some(SpawnInTerminal {
|
||||
id: self.id.clone(),
|
||||
cwd,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue