task: Add re-run task button to terminal title (#12379)

Release Notes:

- Added re-run task button to terminal title.

Close #12277

## Demo


https://github.com/zed-industries/zed/assets/5518/4cd05fa5-4255-412b-8583-68e22f86561e

---------

Co-authored-by: Piotr Osiewicz <piotr@zed.dev>
This commit is contained in:
Jason Lee 2024-05-29 17:40:43 +08:00 committed by GitHub
parent 36d0b71f27
commit 3c6c850390
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 77 additions and 16 deletions

View file

@ -348,9 +348,20 @@ impl Inventory {
})
}
/// Returns the last scheduled task, if any of the sources contains one with the matching id.
pub fn last_scheduled_task(&self) -> Option<(TaskSourceKind, ResolvedTask)> {
self.last_scheduled_tasks.back().cloned()
/// Returns the last scheduled task by task_id if provided.
/// Otherwise, returns the last scheduled task.
pub fn last_scheduled_task(
&self,
task_id: Option<&TaskId>,
) -> Option<(TaskSourceKind, ResolvedTask)> {
if let Some(task_id) = task_id {
self.last_scheduled_tasks
.iter()
.find(|(_, task)| &task.id == task_id)
.cloned()
} else {
self.last_scheduled_tasks.back().cloned()
}
}
/// Registers task "usage" as being scheduled to be used for LRU sorting when listing all tasks.