mirror of https://github.com/helix-editor/helix
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>pull/8034/head
parent
454b61cb21
commit
e5f8d8ef04
|
@ -598,6 +598,9 @@ impl Application {
|
||||||
self.render().await;
|
self.render().await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
EditorEvent::Redraw => {
|
||||||
|
self.render().await;
|
||||||
|
}
|
||||||
EditorEvent::IdleTimer => {
|
EditorEvent::IdleTimer => {
|
||||||
self.editor.clear_idle_timer();
|
self.editor.clear_idle_timer();
|
||||||
self.handle_idle_timeout().await;
|
self.handle_idle_timeout().await;
|
||||||
|
|
|
@ -918,6 +918,7 @@ pub struct Editor {
|
||||||
pub auto_pairs: Option<AutoPairs>,
|
pub auto_pairs: Option<AutoPairs>,
|
||||||
|
|
||||||
pub idle_timer: Pin<Box<Sleep>>,
|
pub idle_timer: Pin<Box<Sleep>>,
|
||||||
|
redraw_timer: Pin<Box<Sleep>>,
|
||||||
last_motion: Option<Motion>,
|
last_motion: Option<Motion>,
|
||||||
pub last_completion: Option<CompleteAction>,
|
pub last_completion: Option<CompleteAction>,
|
||||||
|
|
||||||
|
@ -963,6 +964,7 @@ pub enum EditorEvent {
|
||||||
LanguageServerMessage((usize, Call)),
|
LanguageServerMessage((usize, Call)),
|
||||||
DebuggerEvent(dap::Payload),
|
DebuggerEvent(dap::Payload),
|
||||||
IdleTimer,
|
IdleTimer,
|
||||||
|
Redraw,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
|
@ -1053,6 +1055,7 @@ impl Editor {
|
||||||
status_msg: None,
|
status_msg: None,
|
||||||
autoinfo: None,
|
autoinfo: None,
|
||||||
idle_timer: Box::pin(sleep(conf.idle_timeout)),
|
idle_timer: Box::pin(sleep(conf.idle_timeout)),
|
||||||
|
redraw_timer: Box::pin(sleep(Duration::MAX)),
|
||||||
last_motion: None,
|
last_motion: None,
|
||||||
last_completion: None,
|
last_completion: None,
|
||||||
config,
|
config,
|
||||||
|
@ -1753,12 +1756,16 @@ impl Editor {
|
||||||
if !self.needs_redraw{
|
if !self.needs_redraw{
|
||||||
self.needs_redraw = true;
|
self.needs_redraw = true;
|
||||||
let timeout = Instant::now() + Duration::from_millis(33);
|
let timeout = Instant::now() + Duration::from_millis(33);
|
||||||
if timeout < self.idle_timer.deadline(){
|
if timeout < self.idle_timer.deadline() && timeout < self.redraw_timer.deadline(){
|
||||||
self.idle_timer.as_mut().reset(timeout)
|
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 => {
|
_ = &mut self.idle_timer => {
|
||||||
return EditorEvent::IdleTimer
|
return EditorEvent::IdleTimer
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue