aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/rust-analyzer/src/main_loop.rs39
1 files changed, 24 insertions, 15 deletions
diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs
index 85bde90bb..a64dccd58 100644
--- a/crates/rust-analyzer/src/main_loop.rs
+++ b/crates/rust-analyzer/src/main_loop.rs
@@ -413,20 +413,27 @@ fn loop_turn(
413 if !removed { 413 if !removed {
414 log::error!("unexpected response: {:?}", resp) 414 log::error!("unexpected response: {:?}", resp)
415 } 415 }
416 if Some(&resp.id) == loop_state.configuration_request_id.as_ref() { 416
417 if Some(resp.id) == loop_state.configuration_request_id {
417 loop_state.configuration_request_id.take(); 418 loop_state.configuration_request_id.take();
418 // TODO kb unwrap-unwrap-unwrap 419 if let Some(err) = resp.error {
419 let new_config = 420 log::error!("failed fetch the server settings: {:?}", err)
420 serde_json::from_value::<Vec<ServerConfig>>(resp.result.unwrap()) 421 } else if resp.result.is_none() {
421 .unwrap() 422 log::error!("received empty server settings response from the client")
422 .first() 423 } else {
423 .unwrap() 424 let new_config =
424 .to_owned(); 425 serde_json::from_value::<Vec<ServerConfig>>(resp.result.unwrap())?
425 world_state.update_configuration( 426 .first()
426 new_config.lru_capacity, 427 .expect(
427 get_options(&new_config, text_document_caps), 428 "The client is expected to always send a non-empty config data",
428 get_feature_flags(&new_config, connection), 429 )
429 ); 430 .to_owned();
431 world_state.update_configuration(
432 new_config.lru_capacity,
433 get_options(&new_config, text_document_caps),
434 get_feature_flags(&new_config, connection),
435 );
436 }
430 } 437 }
431 } 438 }
432 }, 439 },
@@ -657,13 +664,15 @@ fn on_notification(
657 Err(not) => not, 664 Err(not) => not,
658 }; 665 };
659 let not = match notification_cast::<req::DidChangeConfiguration>(not) { 666 let not = match notification_cast::<req::DidChangeConfiguration>(not) {
660 Ok(_params) => { 667 Ok(_) => {
668 // As stated in https://github.com/microsoft/language-server-protocol/issues/676,
669 // this notification's parameters should be ignored and the actual config queried separately.
661 let request_id = loop_state.next_request_id(); 670 let request_id = loop_state.next_request_id();
662 let request = request_new::<req::WorkspaceConfiguration>( 671 let request = request_new::<req::WorkspaceConfiguration>(
663 request_id.clone(), 672 request_id.clone(),
664 ConfigurationParams::default(), 673 ConfigurationParams::default(),
665 ); 674 );
666 msg_sender.send(request.into()).unwrap(); 675 msg_sender.send(request.into())?;
667 loop_state.configuration_request_id.replace(request_id); 676 loop_state.configuration_request_id.replace(request_id);
668 677
669 return Ok(()); 678 return Ok(());