on master help sign in
create separate timer for redraw requests (#8023)

* create separate timer for redraw requests * Update helix-view/src/editor.rs Co-authored-by: Michael Davis <mcarsondavis@gmail.com> --------- Co-authored-by: Michael Davis <mcarsondavis@gmail.com>

commite5f8d8ef049b43d20eaf27b4f143bcf808f6cb24 authorPascal Kuthe <pascal.kuthe@semimod.de> dateMon 21 Aug 2023, 23:24 (3 years ago) parent454b61c
2 files changed+12−2
helix-term/src/application.rs+3 helix-view/src/editor.rs+9−2
helix-term/src/application.rs+3
@@ -598,6 +598,9 @@ impl Application {
598598 self.render().await;
599599 }
600600 }
601+ EditorEvent::Redraw => {
602+ self.render().await;
603+ }
601604 EditorEvent::IdleTimer => {
602605 self.editor.clear_idle_timer();
603606 self.handle_idle_timeout().await;
helix-view/src/editor.rs+9−2
@@ -918,6 +918,7 @@ pub struct Editor {
918918 pub auto_pairs: Option<AutoPairs>,
919919
920920 pub idle_timer: Pin<Box<Sleep>>,
921+ redraw_timer: Pin<Box<Sleep>>,
921922 last_motion: Option<Motion>,
922923 pub last_completion: Option<CompleteAction>,
923924
@@ -963,6 +964,7 @@ pub enum EditorEvent {
963964 LanguageServerMessage((usize, Call)),
964965 DebuggerEvent(dap::Payload),
965966 IdleTimer,
967+ Redraw,
966968}
967969
968970#[derive(Debug, Clone)]
@@ -1053,6 +1055,7 @@ impl Editor {
10531055 status_msg: None,
10541056 autoinfo: None,
10551057 idle_timer: Box::pin(sleep(conf.idle_timeout)),
1058+ redraw_timer: Box::pin(sleep(Duration::MAX)),
10561059 last_motion: None,
10571060 last_completion: None,
10581061 config,
@@ -1753,12 +1756,16 @@ impl Editor {
17531756 if !self.needs_redraw{
17541757 self.needs_redraw = true;
17551758 let timeout = Instant::now() + Duration::from_millis(33);
1756− if timeout < self.idle_timer.deadline(){
1757− self.idle_timer.as_mut().reset(timeout)
1759+ if timeout < self.idle_timer.deadline() && timeout < self.redraw_timer.deadline(){
1760+ self.redraw_timer.as_mut().reset(timeout)
17581761 }
17591762 }
17601763 }
17611764
1765+ _ = &mut self.redraw_timer => {
1766+ self.redraw_timer.as_mut().reset(Instant::now() + Duration::from_secs(86400 * 365 * 30));
1767+ return EditorEvent::Redraw
1768+ }
17621769 _ = &mut self.idle_timer => {
17631770 return EditorEvent::IdleTimer
17641771 }