@@ -413,20 +413,27 @@ fn loop_turn(
413413 if !removed {
414414 log:: error!( "unexpected response: {:?}" , resp)
415415 }
416- if Some ( & resp. id ) == loop_state. configuration_request_id . as_ref ( ) {
416+
417+ if Some ( resp. id ) == loop_state. configuration_request_id {
417418 loop_state. configuration_request_id . take ( ) ;
418- // TODO kb unwrap-unwrap-unwrap
419- let new_config =
420- serde_json:: from_value :: < Vec < ServerConfig > > ( resp. result . unwrap ( ) )
421- . unwrap ( )
422- . first ( )
423- . unwrap ( )
424- . to_owned ( ) ;
425- world_state. update_configuration (
426- new_config. lru_capacity ,
427- get_options ( & new_config, text_document_caps) ,
428- get_feature_flags ( & new_config, connection) ,
429- ) ;
419+ if let Some ( err) = resp. error {
420+ log:: error!( "failed fetch the server settings: {:?}" , err)
421+ } else if resp. result . is_none ( ) {
422+ log:: error!( "received empty server settings response from the client" )
423+ } else {
424+ let new_config =
425+ serde_json:: from_value :: < Vec < ServerConfig > > ( resp. result . unwrap ( ) ) ?
426+ . first ( )
427+ . expect (
428+ "The client is expected to always send a non-empty config data" ,
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+ }
430437 }
431438 }
432439 } ,
@@ -657,13 +664,15 @@ fn on_notification(
657664 Err ( not) => not,
658665 } ;
659666 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.
661670 let request_id = loop_state. next_request_id ( ) ;
662671 let request = request_new :: < req:: WorkspaceConfiguration > (
663672 request_id. clone ( ) ,
664673 ConfigurationParams :: default ( ) ,
665674 ) ;
666- msg_sender. send ( request. into ( ) ) . unwrap ( ) ;
675+ msg_sender. send ( request. into ( ) ) ? ;
667676 loop_state. configuration_request_id . replace ( request_id) ;
668677
669678 return Ok ( ( ) ) ;
0 commit comments