From e5f8d8ef049b43d20eaf27b4f143bcf808f6cb24 Mon Sep 17 00:00:00 2001 From: Pascal Kuthe Date: Mon, 21 Aug 2023 23:24:30 +0200 Subject: create separate timer for redraw requests (#8023) * create separate timer for redraw requests * Update helix-view/src/editor.rs Co-authored-by: Michael Davis --------- Co-authored-by: Michael Davis --- helix-view/src/editor.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'helix-view') diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs index 1735b060..94d0a852 100644 --- a/helix-view/src/editor.rs +++ b/helix-view/src/editor.rs @@ -918,6 +918,7 @@ pub struct Editor { pub auto_pairs: Option, pub idle_timer: Pin>, + redraw_timer: Pin>, last_motion: Option, pub last_completion: Option, @@ -963,6 +964,7 @@ pub enum EditorEvent { LanguageServerMessage((usize, Call)), DebuggerEvent(dap::Payload), IdleTimer, + Redraw, } #[derive(Debug, Clone)] @@ -1053,6 +1055,7 @@ impl Editor { status_msg: None, autoinfo: None, idle_timer: Box::pin(sleep(conf.idle_timeout)), + redraw_timer: Box::pin(sleep(Duration::MAX)), last_motion: None, last_completion: None, config, @@ -1753,12 +1756,16 @@ impl Editor { if !self.needs_redraw{ self.needs_redraw = true; let timeout = Instant::now() + Duration::from_millis(33); - if timeout < self.idle_timer.deadline(){ - self.idle_timer.as_mut().reset(timeout) + if timeout < self.idle_timer.deadline() && timeout < self.redraw_timer.deadline(){ + self.redraw_timer.as_mut().reset(timeout) } } } + _ = &mut self.redraw_timer => { + self.redraw_timer.as_mut().reset(Instant::now() + Duration::from_secs(86400 * 365 * 30)); + return EditorEvent::Redraw + } _ = &mut self.idle_timer => { return EditorEvent::IdleTimer } -- cgit v1.2.3-70-g09d2