38ee845b05
While moving completion resolve to the event system in #9668 we introduced what is essentially a "DOS attack" on slow LSPs. Completion resolve requests were made in the render loop and debounced with a timeout. Once the timeout expired the resolve request was made. The problem is the next frame would immediately request a new completion resolve request (and mark the old one as obsolete but because LSP has no notion of cancelation the server would still process it). So we were in essence sending one completion request to the server every 150ms and only stopped if the server managed to respond before we rendered a new frame. This caused overload on slower machines/with slower LS. In this PR I revamped the resolve handler so that a request is only ever resolved once. Both by checking if a request is already in-flight and by marking failed resolve requests as resolved.
29 lines
753 B
Rust
29 lines
753 B
Rust
use std::sync::Arc;
|
|
|
|
use arc_swap::ArcSwap;
|
|
use helix_event::AsyncHook;
|
|
|
|
use crate::config::Config;
|
|
use crate::events;
|
|
use crate::handlers::completion::CompletionHandler;
|
|
use crate::handlers::signature_help::SignatureHelpHandler;
|
|
|
|
pub use completion::trigger_auto_completion;
|
|
pub use helix_view::handlers::Handlers;
|
|
|
|
pub mod completion;
|
|
mod signature_help;
|
|
|
|
pub fn setup(config: Arc<ArcSwap<Config>>) -> Handlers {
|
|
events::register();
|
|
|
|
let completions = CompletionHandler::new(config).spawn();
|
|
let signature_hints = SignatureHelpHandler::new().spawn();
|
|
let handlers = Handlers {
|
|
completions,
|
|
signature_hints,
|
|
};
|
|
completion::register_hooks(&handlers);
|
|
signature_help::register_hooks(&handlers);
|
|
handlers
|
|
}
|