on master help sign in
use redraw handle for debouncing LSP messages (#7538)
618620bPascal Kuthe
helix-term/src/application.rs+1−12
@@ -34,7 +34,6 @@ use std::{
34 io::{stdin, stdout},
34 io::{stdin, stdout},
35 path::Path,
35 path::Path,
36 sync::Arc,
36 sync::Arc,
37− time::{Duration, Instant},
38};
37};
39
38
40use anyhow::{Context, Error};
39use anyhow::{Context, Error};
@@ -45,8 +44,6 @@ use {signal_hook::consts::signal, signal_hook_tokio::Signals};
45#[cfg(windows)]
44#[cfg(windows)]
46type Signals = futures_util::stream::Empty<()>;
45type Signals = futures_util::stream::Empty<()>;
47
46
48−const LSP_DEADLINE: Duration = Duration::from_millis(16);
49−
50#[cfg(not(feature = "integration"))]
47#[cfg(not(feature = "integration"))]
51use tui::backend::CrosstermBackend;
48use tui::backend::CrosstermBackend;
52
49
@@ -76,7 +73,6 @@ pub struct Application {
76 signals: Signals,
73 signals: Signals,
77 jobs: Jobs,
74 jobs: Jobs,
78 lsp_progress: LspProgressMap,
75 lsp_progress: LspProgressMap,
79− last_render: Instant,
80}
76}
81
77
82#[cfg(feature = "integration")]
78#[cfg(feature = "integration")]
@@ -253,7 +249,6 @@ impl Application {
253 signals,
249 signals,
254 jobs: Jobs::new(),
250 jobs: Jobs::new(),
255 lsp_progress: LspProgressMap::new(),
251 lsp_progress: LspProgressMap::new(),
256− last_render: Instant::now(),
257 };
252 };
258
253
259 Ok(app)
254 Ok(app)
@@ -300,7 +295,6 @@ impl Application {
300 S: Stream<Item = crossterm::Result<crossterm::event::Event>> + Unpin,
295 S: Stream<Item = crossterm::Result<crossterm::event::Event>> + Unpin,
301 {
296 {
302 self.render().await;
297 self.render().await;
303− self.last_render = Instant::now();
304
298
305 loop {
299 loop {
306 if !self.event_loop_until_idle(input_stream).await {
300 if !self.event_loop_until_idle(input_stream).await {
@@ -609,12 +603,7 @@ impl Application {
609 EditorEvent::LanguageServerMessage((id, call)) => {
603 EditorEvent::LanguageServerMessage((id, call)) => {
610 self.handle_language_server_message(call, id).await;
604 self.handle_language_server_message(call, id).await;
611 // limit render calls for fast language server messages
605 // limit render calls for fast language server messages
612− let last = self.editor.language_servers.incoming.is_empty();
606+ self.editor.redraw_handle.0.notify_one();
613−
614− if last || self.last_render.elapsed() > LSP_DEADLINE {
615− self.render().await;
616− self.last_render = Instant::now();
617− }
618 }
607 }
619 EditorEvent::DebuggerEvent(payload) => {
608 EditorEvent::DebuggerEvent(payload) => {
620 let needs_render = self.editor.handle_debugger_message(payload).await;
609 let needs_render = self.editor.handle_debugger_message(payload).await;
helix-view/src/editor.rs+1−1
@@ -1705,7 +1705,7 @@ impl Editor {
1705 _ = self.redraw_handle.0.notified() => {
1705 _ = self.redraw_handle.0.notified() => {
1706 if !self.needs_redraw{
1706 if !self.needs_redraw{
1707 self.needs_redraw = true;
1707 self.needs_redraw = true;
1708− let timeout = Instant::now() + Duration::from_millis(96);
1708+ let timeout = Instant::now() + Duration::from_millis(33);
1709 if timeout < self.idle_timer.deadline(){
1709 if timeout < self.idle_timer.deadline(){
1710 self.idle_timer.as_mut().reset(timeout)
1710 self.idle_timer.as_mut().reset(timeout)
1711 }
1711 }