mirror of
https://github.com/zed-industries/zed.git
synced 2024-10-26 00:19:46 +00:00
Fix memory leak of Editor
due to blinking cursors
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
parent
da7bd8439b
commit
e95936c624
1 changed files with 16 additions and 8 deletions
|
@ -2369,11 +2369,14 @@ impl Editor {
|
||||||
cx.notify();
|
cx.notify();
|
||||||
|
|
||||||
let epoch = self.next_blink_epoch();
|
let epoch = self.next_blink_epoch();
|
||||||
cx.spawn(|this, mut cx| async move {
|
cx.spawn(|this, mut cx| {
|
||||||
Timer::after(CURSOR_BLINK_INTERVAL).await;
|
let this = this.downgrade();
|
||||||
this.update(&mut cx, |this, cx| {
|
async move {
|
||||||
this.resume_cursor_blinking(epoch, cx);
|
Timer::after(CURSOR_BLINK_INTERVAL).await;
|
||||||
})
|
if let Some(this) = cx.read(|cx| this.upgrade(cx)) {
|
||||||
|
this.update(&mut cx, |this, cx| this.resume_cursor_blinking(epoch, cx))
|
||||||
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.detach();
|
.detach();
|
||||||
}
|
}
|
||||||
|
@ -2391,9 +2394,14 @@ impl Editor {
|
||||||
cx.notify();
|
cx.notify();
|
||||||
|
|
||||||
let epoch = self.next_blink_epoch();
|
let epoch = self.next_blink_epoch();
|
||||||
cx.spawn(|this, mut cx| async move {
|
cx.spawn(|this, mut cx| {
|
||||||
Timer::after(CURSOR_BLINK_INTERVAL).await;
|
let this = this.downgrade();
|
||||||
this.update(&mut cx, |this, cx| this.blink_cursors(epoch, cx));
|
async move {
|
||||||
|
Timer::after(CURSOR_BLINK_INTERVAL).await;
|
||||||
|
if let Some(this) = cx.read(|cx| this.upgrade(cx)) {
|
||||||
|
this.update(&mut cx, |this, cx| this.blink_cursors(epoch, cx));
|
||||||
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.detach();
|
.detach();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue