Skip to content

Commit a81b147

Browse files
pascalkutheSchuyler Mortimer
authored andcommitted
use redraw handle for debouncing LSP messages (helix-editor#7538)
1 parent 3292794 commit a81b147

File tree

2 files changed

+2
-13
lines changed

2 files changed

+2
-13
lines changed

helix-term/src/application.rs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ use std::{
3838
io::{stdin, stdout},
3939
path::Path,
4040
sync::Arc,
41-
time::{Duration, Instant},
4241
};
4342

4443
use anyhow::{Context, Error};
@@ -49,8 +48,6 @@ use {signal_hook::consts::signal, signal_hook_tokio::Signals};
4948
#[cfg(windows)]
5049
type Signals = futures_util::stream::Empty<()>;
5150

52-
const LSP_DEADLINE: Duration = Duration::from_millis(16);
53-
5451
#[cfg(not(feature = "integration"))]
5552
use tui::backend::CrosstermBackend;
5653

@@ -80,7 +77,6 @@ pub struct Application {
8077
signals: Signals,
8178
jobs: Jobs,
8279
lsp_progress: LspProgressMap,
83-
last_render: Instant,
8480
}
8581

8682
#[cfg(feature = "integration")]
@@ -257,7 +253,6 @@ impl Application {
257253
signals,
258254
jobs: Jobs::new(),
259255
lsp_progress: LspProgressMap::new(),
260-
last_render: Instant::now(),
261256
};
262257

263258
Ok(app)
@@ -304,7 +299,6 @@ impl Application {
304299
S: Stream<Item = crossterm::Result<crossterm::event::Event>> + Unpin,
305300
{
306301
self.render().await;
307-
self.last_render = Instant::now();
308302

309303
loop {
310304
if !self.event_loop_until_idle(input_stream).await {
@@ -613,12 +607,7 @@ impl Application {
613607
EditorEvent::LanguageServerMessage((id, call)) => {
614608
self.handle_language_server_message(call, id).await;
615609
// limit render calls for fast language server messages
616-
let last = self.editor.language_servers.incoming.is_empty();
617-
618-
if last || self.last_render.elapsed() > LSP_DEADLINE {
619-
self.render().await;
620-
self.last_render = Instant::now();
621-
}
610+
self.editor.redraw_handle.0.notify_one();
622611
}
623612
EditorEvent::DebuggerEvent(payload) => {
624613
let needs_render = self.editor.handle_debugger_message(payload).await;

helix-view/src/editor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1705,7 +1705,7 @@ impl Editor {
17051705
_ = self.redraw_handle.0.notified() => {
17061706
if !self.needs_redraw{
17071707
self.needs_redraw = true;
1708-
let timeout = Instant::now() + Duration::from_millis(96);
1708+
let timeout = Instant::now() + Duration::from_millis(33);
17091709
if timeout < self.idle_timer.deadline(){
17101710
self.idle_timer.as_mut().reset(timeout)
17111711
}

0 commit comments

Comments
 (0)