mirror of
https://github.com/zed-industries/zed.git
synced 2024-12-25 01:34:02 +00:00
Merge pull request #1823 from zed-industries/reduce-cursor-blink-load
Reduce Cursor Blink CPU Load
This commit is contained in:
commit
aa9ccf3411
2 changed files with 7 additions and 4 deletions
|
@ -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 {
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Reference in a new issue