File tree Expand file tree Collapse file tree 2 files changed +37
-1
lines changed Expand file tree Collapse file tree 2 files changed +37
-1
lines changed Original file line number Diff line number Diff line change @@ -87,6 +87,42 @@ impl<'a> RequestDispatcher<'a> {
8787 self
8888 }
8989
90+ /// Dispatches the request onto thread pool
91+ pub ( crate ) fn on_no_retry < R > (
92+ & mut self ,
93+ f : fn ( GlobalStateSnapshot , R :: Params ) -> Result < R :: Result > ,
94+ ) -> & mut Self
95+ where
96+ R : lsp_types:: request:: Request + ' static ,
97+ R :: Params : DeserializeOwned + panic:: UnwindSafe + Send + fmt:: Debug ,
98+ R :: Result : Serialize ,
99+ {
100+ let ( req, params, panic_context) = match self . parse :: < R > ( ) {
101+ Some ( it) => it,
102+ None => return self ,
103+ } ;
104+
105+ self . global_state . task_pool . handle . spawn ( {
106+ let world = self . global_state . snapshot ( ) ;
107+ move || {
108+ let result = panic:: catch_unwind ( move || {
109+ let _pctx = stdx:: panic_context:: enter ( panic_context) ;
110+ f ( world, params)
111+ } ) ;
112+ match thread_result_to_response :: < R > ( req. id . clone ( ) , result) {
113+ Ok ( response) => Task :: Response ( response) ,
114+ Err ( _) => Task :: Response ( lsp_server:: Response :: new_err (
115+ req. id ,
116+ lsp_server:: ErrorCode :: ContentModified as i32 ,
117+ "content modified" . to_string ( ) ,
118+ ) ) ,
119+ }
120+ }
121+ } ) ;
122+
123+ self
124+ }
125+
90126 /// Dispatches the request onto thread pool
91127 pub ( crate ) fn on < R > (
92128 & mut self ,
Original file line number Diff line number Diff line change @@ -653,7 +653,7 @@ impl GlobalState {
653653 . on :: < lsp_types:: request:: GotoDeclaration > ( handlers:: handle_goto_declaration)
654654 . on :: < lsp_types:: request:: GotoImplementation > ( handlers:: handle_goto_implementation)
655655 . on :: < lsp_types:: request:: GotoTypeDefinition > ( handlers:: handle_goto_type_definition)
656- . on :: < lsp_types:: request:: InlayHintRequest > ( handlers:: handle_inlay_hints)
656+ . on_no_retry :: < lsp_types:: request:: InlayHintRequest > ( handlers:: handle_inlay_hints)
657657 . on :: < lsp_types:: request:: InlayHintResolveRequest > ( handlers:: handle_inlay_hints_resolve)
658658 . on :: < lsp_types:: request:: Completion > ( handlers:: handle_completion)
659659 . on :: < lsp_types:: request:: ResolveCompletionItem > ( handlers:: handle_completion_resolve)
You can’t perform that action at this time.
0 commit comments