Skip to content

Commit 019f269

Browse files
Process configuration response draft
1 parent 8c4aab0 commit 019f269

File tree

2 files changed

+24
-23
lines changed

2 files changed

+24
-23
lines changed

crates/rust-analyzer/src/main_loop.rs

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ use crate::{
4040
world::{Options, WorldSnapshot, WorldState},
4141
Result, ServerConfig,
4242
};
43+
use req::ConfigurationParams;
4344

4445
#[derive(Debug)]
4546
pub struct LspError {
@@ -336,10 +337,10 @@ struct LoopState {
336337
in_flight_libraries: usize,
337338
pending_libraries: Vec<(SourceRootId, Vec<(FileId, RelativePathBuf, Arc<String>)>)>,
338339
workspace_loaded: bool,
339-
340340
roots_progress_reported: Option<usize>,
341341
roots_scanned: usize,
342342
roots_total: usize,
343+
configuration_request_id: Option<RequestId>,
343344
}
344345

345346
impl LoopState {
@@ -397,15 +398,14 @@ fn loop_turn(
397398
req,
398399
)?,
399400
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)?;
407402
}
408403
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+
}
409409
let removed = loop_state.pending_responses.remove(&resp.id);
410410
if !removed {
411411
log::error!("unexpected response: {:?}", resp)
@@ -569,8 +569,7 @@ fn on_request(
569569
fn on_notification(
570570
msg_sender: &Sender<Message>,
571571
state: &mut WorldState,
572-
pending_requests: &mut PendingRequests,
573-
subs: &mut Subscriptions,
572+
loop_state: &mut LoopState,
574573
not: Notification,
575574
) -> Result<()> {
576575
let not = match notification_cast::<req::Cancel>(not) {
@@ -579,7 +578,7 @@ fn on_notification(
579578
NumberOrString::Number(id) => id.into(),
580579
NumberOrString::String(id) => id.into(),
581580
};
582-
if pending_requests.cancel(&id) {
581+
if loop_state.pending_requests.cancel(&id) {
583582
let response = Response::new_err(
584583
id,
585584
ErrorCode::RequestCanceled as i32,
@@ -598,7 +597,7 @@ fn on_notification(
598597
if let Some(file_id) =
599598
state.vfs.write().add_file_overlay(&path, params.text_document.text)
600599
{
601-
subs.add_sub(FileId(file_id.0));
600+
loop_state.subscriptions.add_sub(FileId(file_id.0));
602601
}
603602
return Ok(());
604603
}
@@ -629,7 +628,7 @@ fn on_notification(
629628
let uri = params.text_document.uri;
630629
let path = uri.to_file_path().map_err(|()| format!("invalid uri: {}", uri))?;
631630
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));
633632
}
634633
let params =
635634
req::PublishDiagnosticsParams { uri, diagnostics: Vec::new(), version: None };
@@ -641,15 +640,17 @@ fn on_notification(
641640
};
642641
let not = match notification_cast::<req::DidChangeConfiguration>(not) {
643642
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+
650651
return Ok(());
651652
}
652-
Err(not) => dbg!(not),
653+
Err(not) => not,
653654
};
654655
let not = match notification_cast::<req::DidChangeWatchedFiles>(not) {
655656
Ok(params) => {

editors/code/src/config.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ export class Config {
1212
private readonly requiresReloadOpts = [
1313
"serverPath",
1414
"cargoFeatures",
15-
"cargo-watch",
16-
"highlighting.semanticTokens",
17-
"inlayHints",
15+
"excludeGlobs",
16+
"useClientWatching",
17+
"highlighting",
1818
"updates.channel",
1919
]
2020
.map(opt => `${this.rootSection}.${opt}`);

0 commit comments

Comments
 (0)