@@ -40,6 +40,7 @@ use crate::{
40
40
world:: { Options , WorldSnapshot , WorldState } ,
41
41
Result , ServerConfig ,
42
42
} ;
43
+ use req:: ConfigurationParams ;
43
44
44
45
#[ derive( Debug ) ]
45
46
pub struct LspError {
@@ -336,10 +337,10 @@ struct LoopState {
336
337
in_flight_libraries : usize ,
337
338
pending_libraries : Vec < ( SourceRootId , Vec < ( FileId , RelativePathBuf , Arc < String > ) > ) > ,
338
339
workspace_loaded : bool ,
339
-
340
340
roots_progress_reported : Option < usize > ,
341
341
roots_scanned : usize ,
342
342
roots_total : usize ,
343
+ configuration_request_id : Option < RequestId > ,
343
344
}
344
345
345
346
impl LoopState {
@@ -397,15 +398,14 @@ fn loop_turn(
397
398
req,
398
399
) ?,
399
400
Message :: Notification ( not) => {
400
- on_notification (
401
- & connection. sender ,
402
- world_state,
403
- & mut loop_state. pending_requests ,
404
- & mut loop_state. subscriptions ,
405
- not,
406
- ) ?;
401
+ on_notification ( & connection. sender , world_state, loop_state, not) ?;
407
402
}
408
403
Message :: Response ( resp) => {
404
+ if Some ( & resp. id ) == loop_state. configuration_request_id . as_ref ( ) {
405
+ loop_state. configuration_request_id . take ( ) ;
406
+ eprintln ! ( "!!!!!!!!!!!!!!1" ) ;
407
+ dbg ! ( & resp) ;
408
+ }
409
409
let removed = loop_state. pending_responses . remove ( & resp. id ) ;
410
410
if !removed {
411
411
log:: error!( "unexpected response: {:?}" , resp)
@@ -569,8 +569,7 @@ fn on_request(
569
569
fn on_notification (
570
570
msg_sender : & Sender < Message > ,
571
571
state : & mut WorldState ,
572
- pending_requests : & mut PendingRequests ,
573
- subs : & mut Subscriptions ,
572
+ loop_state : & mut LoopState ,
574
573
not : Notification ,
575
574
) -> Result < ( ) > {
576
575
let not = match notification_cast :: < req:: Cancel > ( not) {
@@ -579,7 +578,7 @@ fn on_notification(
579
578
NumberOrString :: Number ( id) => id. into ( ) ,
580
579
NumberOrString :: String ( id) => id. into ( ) ,
581
580
} ;
582
- if pending_requests. cancel ( & id) {
581
+ if loop_state . pending_requests . cancel ( & id) {
583
582
let response = Response :: new_err (
584
583
id,
585
584
ErrorCode :: RequestCanceled as i32 ,
@@ -598,7 +597,7 @@ fn on_notification(
598
597
if let Some ( file_id) =
599
598
state. vfs . write ( ) . add_file_overlay ( & path, params. text_document . text )
600
599
{
601
- subs . add_sub ( FileId ( file_id. 0 ) ) ;
600
+ loop_state . subscriptions . add_sub ( FileId ( file_id. 0 ) ) ;
602
601
}
603
602
return Ok ( ( ) ) ;
604
603
}
@@ -629,7 +628,7 @@ fn on_notification(
629
628
let uri = params. text_document . uri ;
630
629
let path = uri. to_file_path ( ) . map_err ( |( ) | format ! ( "invalid uri: {}" , uri) ) ?;
631
630
if let Some ( file_id) = state. vfs . write ( ) . remove_file_overlay ( path. as_path ( ) ) {
632
- subs . remove_sub ( FileId ( file_id. 0 ) ) ;
631
+ loop_state . subscriptions . remove_sub ( FileId ( file_id. 0 ) ) ;
633
632
}
634
633
let params =
635
634
req:: PublishDiagnosticsParams { uri, diagnostics : Vec :: new ( ) , version : None } ;
@@ -641,15 +640,17 @@ fn on_notification(
641
640
} ;
642
641
let not = match notification_cast :: < req:: DidChangeConfiguration > ( not) {
643
642
Ok ( _params) => {
644
- dbg ! ( _params) ;
645
- // let request = request_new::<req::WorkspaceConfiguration>(
646
- // loop_state.next_request_id(),
647
- // ConfigurationParams::default(),
648
- // );
649
- // let zz = connection.sender.send(request.into()).unwrap();
643
+ let request_id = loop_state. next_request_id ( ) ;
644
+ let request = request_new :: < req:: WorkspaceConfiguration > (
645
+ request_id. clone ( ) ,
646
+ ConfigurationParams :: default ( ) ,
647
+ ) ;
648
+ msg_sender. send ( request. into ( ) ) . unwrap ( ) ;
649
+ loop_state. configuration_request_id . replace ( request_id) ;
650
+
650
651
return Ok ( ( ) ) ;
651
652
}
652
- Err ( not) => dbg ! ( not) ,
653
+ Err ( not) => not,
653
654
} ;
654
655
let not = match notification_cast :: < req:: DidChangeWatchedFiles > ( not) {
655
656
Ok ( params) => {
0 commit comments