Add basic bash and Python tasks (#10548)
Part of https://github.com/zed-industries/zed/issues/5141 * adds "run selection" and "run file" tasks for bash and Python. * replaces newlines with `\n` symbols in the human-readable task labels * properly escapes task command arguments when spawning the task in terminal Caveats: * bash tasks will always use user's default shell to spawn the selections, but they should rather respect the shebang line even if it's not selected * Python tasks will always use `python3` to spawn its tasks now, as there's no proper mechanism in Zed to deal with different Python executables Release Notes: - Added tasks for bash and Python to execute selections and open files in terminal
This commit is contained in:
parent
1911a9f39b
commit
db48c75231
11 changed files with 100 additions and 17 deletions
|
@ -214,15 +214,20 @@ impl Inventory {
|
|||
.flat_map(|task| Some((task_source_kind.as_ref()?, task)));
|
||||
|
||||
let mut lru_score = 0_u32;
|
||||
let mut task_usage = self.last_scheduled_tasks.iter().rev().fold(
|
||||
HashMap::default(),
|
||||
|mut tasks, (task_source_kind, resolved_task)| {
|
||||
tasks
|
||||
.entry(&resolved_task.id)
|
||||
.or_insert_with(|| (task_source_kind, resolved_task, post_inc(&mut lru_score)));
|
||||
tasks
|
||||
},
|
||||
);
|
||||
let mut task_usage = self
|
||||
.last_scheduled_tasks
|
||||
.iter()
|
||||
.rev()
|
||||
.filter(|(_, task)| !task.original_task().ignore_previously_resolved)
|
||||
.fold(
|
||||
HashMap::default(),
|
||||
|mut tasks, (task_source_kind, resolved_task)| {
|
||||
tasks.entry(&resolved_task.id).or_insert_with(|| {
|
||||
(task_source_kind, resolved_task, post_inc(&mut lru_score))
|
||||
});
|
||||
tasks
|
||||
},
|
||||
);
|
||||
let not_used_score = post_inc(&mut lru_score);
|
||||
let current_resolved_tasks = self
|
||||
.sources
|
||||
|
|
|
@ -44,6 +44,7 @@ impl Project {
|
|||
.unwrap_or_else(|| Path::new(""));
|
||||
|
||||
let (spawn_task, shell) = if let Some(spawn_task) = spawn_task {
|
||||
log::debug!("Spawning task: {spawn_task:?}");
|
||||
env.extend(spawn_task.env);
|
||||
// Activate minimal Python virtual environment
|
||||
if let Some(python_settings) = &python_settings.as_option() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue