mirror of https://github.com/helix-editor/helix
use redraw handle for debouncing LSP messages (#7538)
parent
dc50263ed0
commit
618620b369
|
@ -34,7 +34,6 @@ use std::{
|
||||||
io::{stdin, stdout},
|
io::{stdin, stdout},
|
||||||
path::Path,
|
path::Path,
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
time::{Duration, Instant},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use anyhow::{Context, Error};
|
use anyhow::{Context, Error};
|
||||||
|
@ -45,8 +44,6 @@ use {signal_hook::consts::signal, signal_hook_tokio::Signals};
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
type Signals = futures_util::stream::Empty<()>;
|
type Signals = futures_util::stream::Empty<()>;
|
||||||
|
|
||||||
const LSP_DEADLINE: Duration = Duration::from_millis(16);
|
|
||||||
|
|
||||||
#[cfg(not(feature = "integration"))]
|
#[cfg(not(feature = "integration"))]
|
||||||
use tui::backend::CrosstermBackend;
|
use tui::backend::CrosstermBackend;
|
||||||
|
|
||||||
|
@ -76,7 +73,6 @@ pub struct Application {
|
||||||
signals: Signals,
|
signals: Signals,
|
||||||
jobs: Jobs,
|
jobs: Jobs,
|
||||||
lsp_progress: LspProgressMap,
|
lsp_progress: LspProgressMap,
|
||||||
last_render: Instant,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "integration")]
|
#[cfg(feature = "integration")]
|
||||||
|
@ -253,7 +249,6 @@ impl Application {
|
||||||
signals,
|
signals,
|
||||||
jobs: Jobs::new(),
|
jobs: Jobs::new(),
|
||||||
lsp_progress: LspProgressMap::new(),
|
lsp_progress: LspProgressMap::new(),
|
||||||
last_render: Instant::now(),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(app)
|
Ok(app)
|
||||||
|
@ -300,7 +295,6 @@ impl Application {
|
||||||
S: Stream<Item = crossterm::Result<crossterm::event::Event>> + Unpin,
|
S: Stream<Item = crossterm::Result<crossterm::event::Event>> + Unpin,
|
||||||
{
|
{
|
||||||
self.render().await;
|
self.render().await;
|
||||||
self.last_render = Instant::now();
|
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
if !self.event_loop_until_idle(input_stream).await {
|
if !self.event_loop_until_idle(input_stream).await {
|
||||||
|
@ -609,12 +603,7 @@ impl Application {
|
||||||
EditorEvent::LanguageServerMessage((id, call)) => {
|
EditorEvent::LanguageServerMessage((id, call)) => {
|
||||||
self.handle_language_server_message(call, id).await;
|
self.handle_language_server_message(call, id).await;
|
||||||
// limit render calls for fast language server messages
|
// limit render calls for fast language server messages
|
||||||
let last = self.editor.language_servers.incoming.is_empty();
|
self.editor.redraw_handle.0.notify_one();
|
||||||
|
|
||||||
if last || self.last_render.elapsed() > LSP_DEADLINE {
|
|
||||||
self.render().await;
|
|
||||||
self.last_render = Instant::now();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
EditorEvent::DebuggerEvent(payload) => {
|
EditorEvent::DebuggerEvent(payload) => {
|
||||||
let needs_render = self.editor.handle_debugger_message(payload).await;
|
let needs_render = self.editor.handle_debugger_message(payload).await;
|
||||||
|
|
|
@ -1705,7 +1705,7 @@ impl Editor {
|
||||||
_ = self.redraw_handle.0.notified() => {
|
_ = self.redraw_handle.0.notified() => {
|
||||||
if !self.needs_redraw{
|
if !self.needs_redraw{
|
||||||
self.needs_redraw = true;
|
self.needs_redraw = true;
|
||||||
let timeout = Instant::now() + Duration::from_millis(96);
|
let timeout = Instant::now() + Duration::from_millis(33);
|
||||||
if timeout < self.idle_timer.deadline(){
|
if timeout < self.idle_timer.deadline(){
|
||||||
self.idle_timer.as_mut().reset(timeout)
|
self.idle_timer.as_mut().reset(timeout)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue