Merge pull request #1823 from zed-industries/reduce-cursor-blink-load

Reduce Cursor Blink CPU Load
This commit is contained in:
Kay Simmons 2022-10-26 17:58:56 -07:00 committed by GitHub
commit aa9ccf3411
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 4 deletions

View file

@ -30,7 +30,7 @@ impl BlinkManager {
blink_epoch: 0,
blinking_paused: false,
visible: true,
enabled: true,
enabled: false,
}
}
@ -71,6 +71,7 @@ impl BlinkManager {
if epoch == self.blink_epoch && self.enabled && !self.blinking_paused {
self.visible = !self.visible;
cx.notify();
dbg!(cx.handle());
let epoch = self.next_blink_epoch();
let interval = self.blink_interval;
@ -96,8 +97,8 @@ impl BlinkManager {
self.blink_cursors(self.blink_epoch, cx);
}
pub fn disable(&mut self, _: &mut ModelContext<Self>) {
self.enabled = true;
pub fn disable(&mut self, _cx: &mut ModelContext<Self>) {
self.enabled = false;
}
pub fn visible(&self) -> bool {

View file

@ -6511,8 +6511,10 @@ impl View for Editor {
if let Some(rename) = self.pending_rename.as_ref() {
cx.focus(&rename.editor);
} else {
self.focused = true;
if !self.focused {
self.blink_manager.update(cx, BlinkManager::enable);
}
self.focused = true;
self.buffer.update(cx, |buffer, cx| {
buffer.finalize_last_transaction(cx);
if self.leader_replica_id.is_none() {