Fix tasks not being stopped on reruns (#29786)

Follow-up of https://github.com/zed-industries/zed/pull/28993

* Tone down tasks' cancellation logging
* Fix task terminals' leak, disallowing to fully cancel the task by
dropping the terminal off the pane:

f619d5f02a/crates/terminal_view/src/terminal_panel.rs (L1464-L1471)

Release Notes:

- Fixed tasks not being stopped on reruns
This commit is contained in:
Kirill Bulatov 2025-05-02 14:45:43 +03:00 committed by GitHub
parent 460ac96df4
commit e14d078f8a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 69 additions and 41 deletions

View file

@ -46,7 +46,7 @@ use smol::channel::{Receiver, Sender};
use task::{HideStrategy, Shell, TaskId};
use terminal_settings::{AlternateScroll, CursorShape, TerminalSettings};
use theme::{ActiveTheme, Theme};
use util::{ResultExt, paths::home_dir, truncate_and_trailoff};
use util::{paths::home_dir, truncate_and_trailoff};
use std::{
cmp::{self, min},
@ -1851,8 +1851,7 @@ impl Terminal {
if let Some(task) = self.task() {
if task.status == TaskStatus::Running {
let completion_receiver = task.completion_rx.clone();
return cx
.spawn(async move |_| completion_receiver.recv().await.log_err().flatten());
return cx.spawn(async move |_| completion_receiver.recv().await.ok().flatten());
} else if let Ok(status) = task.completion_rx.try_recv() {
return Task::ready(status);
}