fix: wrong resetting of the cursor after the task canceled

This commit is contained in:
sxyazi 2023-09-03 00:34:23 +08:00
parent b49de866c1
commit 51e1110ca0
No known key found for this signature in database

View file

@ -121,12 +121,12 @@ impl Tasks {
}
pub fn cancel(&mut self) -> bool {
let id = self.scheduler.running.read().get_id(self.cursor);
if !id.map(|id| self.scheduler.cancel(id)).unwrap_or(false) {
let running = self.scheduler.running.read();
if !running.get_id(self.cursor).map(|id| self.scheduler.cancel(id)).unwrap_or(false) {
return false;
}
self.next();
self.cursor = self.cursor.min(running.len().saturating_sub(1));
true
}