@@ -173,8 +173,10 @@ impl GlobalState {
173173 }
174174
175175 if self . config . discover_workspace_config ( ) . is_none ( ) {
176- let req = FetchWorkspaceRequest { path : None , force_crate_graph_reload : false } ;
177- self . fetch_workspaces_queue . request_op ( "startup" . to_owned ( ) , req) ;
176+ self . fetch_workspaces_queue . request_op (
177+ "startup" . to_owned ( ) ,
178+ FetchWorkspaceRequest { path : None , force_crate_graph_reload : false } ,
179+ ) ;
178180 if let Some ( ( cause, FetchWorkspaceRequest { path, force_crate_graph_reload } ) ) =
179181 self . fetch_workspaces_queue . should_start_op ( )
180182 {
@@ -545,6 +547,10 @@ impl GlobalState {
545547 let snapshot = self . snapshot ( ) ;
546548 self . task_pool . handle . spawn_with_sender ( ThreadIntent :: LatencySensitive , {
547549 let subscriptions = subscriptions. clone ( ) ;
550+ // Do not fetch semantic diagnostics (and populate query results) if we haven't even
551+ // loaded the initial workspace yet.
552+ let fetch_semantic =
553+ self . vfs_done && self . fetch_workspaces_queue . last_op_result ( ) . is_some ( ) ;
548554 move |sender| {
549555 let diags = fetch_native_diagnostics (
550556 & snapshot,
@@ -556,22 +562,29 @@ impl GlobalState {
556562 . send ( Task :: Diagnostics ( DiagnosticsTaskKind :: Syntax ( generation, diags) ) )
557563 . unwrap ( ) ;
558564
559- let diags = fetch_native_diagnostics (
560- & snapshot,
561- subscriptions,
562- slice,
563- NativeDiagnosticsFetchKind :: Semantic ,
564- ) ;
565- sender
566- . send ( Task :: Diagnostics ( DiagnosticsTaskKind :: Semantic ( generation, diags) ) )
567- . unwrap ( ) ;
565+ if fetch_semantic {
566+ let diags = fetch_native_diagnostics (
567+ & snapshot,
568+ subscriptions,
569+ slice,
570+ NativeDiagnosticsFetchKind :: Semantic ,
571+ ) ;
572+ sender
573+ . send ( Task :: Diagnostics ( DiagnosticsTaskKind :: Semantic (
574+ generation, diags,
575+ ) ) )
576+ . unwrap ( ) ;
577+ }
568578 }
569579 } ) ;
570580 start = end;
571581 }
572582 }
573583
574584 fn update_tests ( & mut self ) {
585+ if !self . vfs_done {
586+ return ;
587+ }
575588 let db = self . analysis_host . raw_database ( ) ;
576589 let subscriptions = self
577590 . mem_docs
@@ -1052,9 +1065,9 @@ impl GlobalState {
10521065 . on :: < NO_RETRY , lsp_request:: GotoImplementation > ( handlers:: handle_goto_implementation)
10531066 . on :: < NO_RETRY , lsp_request:: GotoTypeDefinition > ( handlers:: handle_goto_type_definition)
10541067 . on :: < NO_RETRY , lsp_request:: InlayHintRequest > ( handlers:: handle_inlay_hints)
1055- . on :: < NO_RETRY , lsp_request:: InlayHintResolveRequest > ( handlers:: handle_inlay_hints_resolve)
1068+ . on_identity :: < NO_RETRY , lsp_request:: InlayHintResolveRequest , _ > ( handlers:: handle_inlay_hints_resolve)
10561069 . on :: < NO_RETRY , lsp_request:: CodeLensRequest > ( handlers:: handle_code_lens)
1057- . on :: < NO_RETRY , lsp_request:: CodeLensResolve > ( handlers:: handle_code_lens_resolve)
1070+ . on_identity :: < NO_RETRY , lsp_request:: CodeLensResolve , _ > ( handlers:: handle_code_lens_resolve)
10581071 . on :: < NO_RETRY , lsp_request:: PrepareRenameRequest > ( handlers:: handle_prepare_rename)
10591072 . on :: < NO_RETRY , lsp_request:: Rename > ( handlers:: handle_rename)
10601073 . on :: < NO_RETRY , lsp_request:: References > ( handlers:: handle_references)
@@ -1081,7 +1094,7 @@ impl GlobalState {
10811094 . on :: < NO_RETRY , lsp_ext:: Runnables > ( handlers:: handle_runnables)
10821095 . on :: < NO_RETRY , lsp_ext:: RelatedTests > ( handlers:: handle_related_tests)
10831096 . on :: < NO_RETRY , lsp_ext:: CodeActionRequest > ( handlers:: handle_code_action)
1084- . on :: < RETRY , lsp_ext:: CodeActionResolveRequest > ( handlers:: handle_code_action_resolve)
1097+ . on_identity :: < RETRY , lsp_ext:: CodeActionResolveRequest , _ > ( handlers:: handle_code_action_resolve)
10851098 . on :: < NO_RETRY , lsp_ext:: HoverRequest > ( handlers:: handle_hover)
10861099 . on :: < NO_RETRY , lsp_ext:: ExternalDocs > ( handlers:: handle_open_docs)
10871100 . on :: < NO_RETRY , lsp_ext:: OpenCargoToml > ( handlers:: handle_open_cargo_toml)
0 commit comments