mirror of
https://github.com/zed-industries/zed.git
synced 2025-02-06 10:42:08 +00:00
Use a weak handle to poll local worktree snapshot
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
parent
83a3402235
commit
0bb7189842
1 changed files with 7 additions and 5 deletions
|
@ -384,16 +384,18 @@ impl Worktree {
|
||||||
worktree.snapshot = worktree.background_snapshot.lock().clone();
|
worktree.snapshot = worktree.background_snapshot.lock().clone();
|
||||||
if worktree.is_scanning() {
|
if worktree.is_scanning() {
|
||||||
if worktree.poll_task.is_none() {
|
if worktree.poll_task.is_none() {
|
||||||
worktree.poll_task = Some(cx.spawn(|this, mut cx| async move {
|
worktree.poll_task = Some(cx.spawn_weak(|this, mut cx| async move {
|
||||||
if is_fake_fs {
|
if is_fake_fs {
|
||||||
cx.background().simulate_random_delay().await;
|
cx.background().simulate_random_delay().await;
|
||||||
} else {
|
} else {
|
||||||
smol::Timer::after(Duration::from_millis(100)).await;
|
smol::Timer::after(Duration::from_millis(100)).await;
|
||||||
}
|
}
|
||||||
|
if let Some(this) = this.upgrade(&cx) {
|
||||||
this.update(&mut cx, |this, cx| {
|
this.update(&mut cx, |this, cx| {
|
||||||
this.as_local_mut().unwrap().poll_task = None;
|
this.as_local_mut().unwrap().poll_task = None;
|
||||||
this.poll_snapshot(cx);
|
this.poll_snapshot(cx);
|
||||||
})
|
});
|
||||||
|
}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue