Skip to content

Commit 618620b

Browse files
authored
use redraw handle for debouncing LSP messages (#7538)
1 parent dc50263 commit 618620b

File tree

2 files changed

+2
-13
lines changed

2 files changed

+2
-13
lines changed

helix-term/src/application.rs

+1-12
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ use std::{
3434
io::{stdin, stdout},
3535
path::Path,
3636
sync::Arc,
37-
time::{Duration, Instant},
3837
};
3938

4039
use anyhow::{Context, Error};
@@ -45,8 +44,6 @@ use {signal_hook::consts::signal, signal_hook_tokio::Signals};
4544
#[cfg(windows)]
4645
type Signals = futures_util::stream::Empty<()>;
4746

48-
const LSP_DEADLINE: Duration = Duration::from_millis(16);
49-
5047
#[cfg(not(feature = "integration"))]
5148
use tui::backend::CrosstermBackend;
5249

@@ -76,7 +73,6 @@ pub struct Application {
7673
signals: Signals,
7774
jobs: Jobs,
7875
lsp_progress: LspProgressMap,
79-
last_render: Instant,
8076
}
8177

8278
#[cfg(feature = "integration")]
@@ -253,7 +249,6 @@ impl Application {
253249
signals,
254250
jobs: Jobs::new(),
255251
lsp_progress: LspProgressMap::new(),
256-
last_render: Instant::now(),
257252
};
258253

259254
Ok(app)
@@ -300,7 +295,6 @@ impl Application {
300295
S: Stream<Item = crossterm::Result<crossterm::event::Event>> + Unpin,
301296
{
302297
self.render().await;
303-
self.last_render = Instant::now();
304298

305299
loop {
306300
if !self.event_loop_until_idle(input_stream).await {
@@ -609,12 +603,7 @@ impl Application {
609603
EditorEvent::LanguageServerMessage((id, call)) => {
610604
self.handle_language_server_message(call, id).await;
611605
// limit render calls for fast language server messages
612-
let last = self.editor.language_servers.incoming.is_empty();
613-
614-
if last || self.last_render.elapsed() > LSP_DEADLINE {
615-
self.render().await;
616-
self.last_render = Instant::now();
617-
}
606+
self.editor.redraw_handle.0.notify_one();
618607
}
619608
EditorEvent::DebuggerEvent(payload) => {
620609
let needs_render = self.editor.handle_debugger_message(payload).await;

helix-view/src/editor.rs

+1-1
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)