Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create separate timer for redraw requests #8023

Merged
merged 2 commits into from
Aug 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions helix-term/src/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,9 @@ impl Application {
self.render().await;
}
}
EditorEvent::Redraw => {
self.render().await;
}
EditorEvent::IdleTimer => {
self.editor.clear_idle_timer();
self.handle_idle_timeout().await;
Expand Down
11 changes: 9 additions & 2 deletions helix-view/src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -918,6 +918,7 @@ pub struct Editor {
pub auto_pairs: Option<AutoPairs>,

pub idle_timer: Pin<Box<Sleep>>,
redraw_timer: Pin<Box<Sleep>>,
last_motion: Option<Motion>,
pub last_completion: Option<CompleteAction>,

Expand Down Expand Up @@ -963,6 +964,7 @@ pub enum EditorEvent {
LanguageServerMessage((usize, Call)),
DebuggerEvent(dap::Payload),
IdleTimer,
Redraw,
}

#[derive(Debug, Clone)]
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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(){
the-mikedavis marked this conversation as resolved.
Show resolved Hide resolved
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
}
Expand Down
Loading