mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-15 01:17:27 +00:00
Auto merge of #14359 - Veykril:opt-out-retry, r=Veykril
fix: Do not retry inlay hint requests Should close https://github.com/rust-lang/rust-analyzer/issues/13372, retrying the way its currently implemented is not ideal as we do not adjust offsets in the requests, but doing that is a major PITA, so this should at least work around one of the more annoying issues stemming from it.
This commit is contained in:
commit
adbda94303
2 changed files with 37 additions and 1 deletions
|
@ -87,6 +87,42 @@ impl<'a> RequestDispatcher<'a> {
|
|||
self
|
||||
}
|
||||
|
||||
/// Dispatches the request onto thread pool
|
||||
pub(crate) fn on_no_retry<R>(
|
||||
&mut self,
|
||||
f: fn(GlobalStateSnapshot, R::Params) -> Result<R::Result>,
|
||||
) -> &mut Self
|
||||
where
|
||||
R: lsp_types::request::Request + 'static,
|
||||
R::Params: DeserializeOwned + panic::UnwindSafe + Send + fmt::Debug,
|
||||
R::Result: Serialize,
|
||||
{
|
||||
let (req, params, panic_context) = match self.parse::<R>() {
|
||||
Some(it) => it,
|
||||
None => return self,
|
||||
};
|
||||
|
||||
self.global_state.task_pool.handle.spawn({
|
||||
let world = self.global_state.snapshot();
|
||||
move || {
|
||||
let result = panic::catch_unwind(move || {
|
||||
let _pctx = stdx::panic_context::enter(panic_context);
|
||||
f(world, params)
|
||||
});
|
||||
match thread_result_to_response::<R>(req.id.clone(), result) {
|
||||
Ok(response) => Task::Response(response),
|
||||
Err(_) => Task::Response(lsp_server::Response::new_err(
|
||||
req.id,
|
||||
lsp_server::ErrorCode::ContentModified as i32,
|
||||
"content modified".to_string(),
|
||||
)),
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
self
|
||||
}
|
||||
|
||||
/// Dispatches the request onto thread pool
|
||||
pub(crate) fn on<R>(
|
||||
&mut self,
|
||||
|
|
|
@ -663,7 +663,7 @@ impl GlobalState {
|
|||
.on::<lsp_types::request::GotoDeclaration>(handlers::handle_goto_declaration)
|
||||
.on::<lsp_types::request::GotoImplementation>(handlers::handle_goto_implementation)
|
||||
.on::<lsp_types::request::GotoTypeDefinition>(handlers::handle_goto_type_definition)
|
||||
.on::<lsp_types::request::InlayHintRequest>(handlers::handle_inlay_hints)
|
||||
.on_no_retry::<lsp_types::request::InlayHintRequest>(handlers::handle_inlay_hints)
|
||||
.on::<lsp_types::request::InlayHintResolveRequest>(handlers::handle_inlay_hints_resolve)
|
||||
.on::<lsp_types::request::Completion>(handlers::handle_completion)
|
||||
.on::<lsp_types::request::ResolveCompletionItem>(handlers::handle_completion_resolve)
|
||||
|
|
Loading…
Reference in a new issue