@@ -607,30 +607,34 @@ impl GlobalState {
607
607
608
608
/// Handles a request.
609
609
fn on_request ( & mut self , req : Request ) {
610
- if self . shutdown_requested {
611
- self . respond ( lsp_server:: Response :: new_err (
612
- req. id ,
613
- lsp_server:: ErrorCode :: InvalidRequest as i32 ,
614
- "Shutdown already requested." . to_owned ( ) ,
615
- ) ) ;
616
- return ;
617
- }
610
+ let mut dispatcher = RequestDispatcher { req : Some ( req) , global_state : self } ;
611
+ dispatcher. on_sync_mut :: < lsp_types:: request:: Shutdown > ( |s, ( ) | {
612
+ s. shutdown_requested = true ;
613
+ Ok ( ( ) )
614
+ } ) ;
615
+
616
+ if let RequestDispatcher { req : Some ( req) , global_state : this } = & mut dispatcher {
617
+ if this. shutdown_requested {
618
+ this. respond ( lsp_server:: Response :: new_err (
619
+ req. id . clone ( ) ,
620
+ lsp_server:: ErrorCode :: InvalidRequest as i32 ,
621
+ "Shutdown already requested." . to_owned ( ) ,
622
+ ) ) ;
623
+ return ;
624
+ }
618
625
619
- // Avoid flashing a bunch of unresolved references during initial load.
620
- if self . workspaces . is_empty ( ) && !self . is_quiescent ( ) {
621
- self . respond ( lsp_server:: Response :: new_err (
622
- req. id ,
623
- lsp_server:: ErrorCode :: ContentModified as i32 ,
624
- "waiting for cargo metadata or cargo check" . to_owned ( ) ,
625
- ) ) ;
626
- return ;
626
+ // Avoid flashing a bunch of unresolved references during initial load.
627
+ if this. workspaces . is_empty ( ) && !this. is_quiescent ( ) {
628
+ this. respond ( lsp_server:: Response :: new_err (
629
+ req. id . clone ( ) ,
630
+ lsp_server:: ErrorCode :: ContentModified as i32 ,
631
+ "waiting for cargo metadata or cargo check" . to_owned ( ) ,
632
+ ) ) ;
633
+ return ;
634
+ }
627
635
}
628
636
629
- RequestDispatcher { req : Some ( req) , global_state : self }
630
- . on_sync_mut :: < lsp_types:: request:: Shutdown > ( |s, ( ) | {
631
- s. shutdown_requested = true ;
632
- Ok ( ( ) )
633
- } )
637
+ dispatcher
634
638
. on_sync_mut :: < lsp_ext:: ReloadWorkspace > ( handlers:: handle_workspace_reload)
635
639
. on_sync_mut :: < lsp_ext:: MemoryUsage > ( handlers:: handle_memory_usage)
636
640
. on_sync_mut :: < lsp_ext:: ShuffleCrateGraph > ( handlers:: handle_shuffle_crate_graph)
0 commit comments