Skip to content

Commit

Permalink
fix(lsp): properly reply to unknown requests
Browse files Browse the repository at this point in the history
  • Loading branch information
dnaka91 committed Dec 13, 2023
1 parent 740c46d commit 6bb08d5
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions crates/stef-lsp/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ impl Backend {
let settings = serde_json::from_value(settings.remove(0))
.context("failed to parse raw configuration")?;

debug!("configuration loaded: {settings:#?}");
debug!(settings = as_debug!(settings); "configuration loaded");

self.settings = settings;

Expand Down Expand Up @@ -446,11 +446,21 @@ fn main_loop(conn: &Connection, mut server: impl LanguageServer) -> Result<()> {
)?;
}

_ => debug!("got request: {req:?}"),
_ => {
debug!(request = as_debug!(req); "got unsupported request");
conn.sender.send(
Response::new_err(
req.id,
ErrorCode::MethodNotFound as _,
format!("request `{}` not supported", req.method),
)
.into(),
)?;
}
}
}
lsp_server::Message::Response(resp) => {
debug!("got response: {resp:?}");
debug!(response = as_debug!(resp); "got unexpected response");
}
lsp_server::Message::Notification(notif) => match notif.method.as_str() {
Initialized::METHOD => {
Expand All @@ -468,7 +478,7 @@ fn main_loop(conn: &Connection, mut server: impl LanguageServer) -> Result<()> {
DidChangeConfiguration::METHOD => {
server.did_change_configuration(cast_notify::<DidChangeConfiguration>(notif)?);
}
_ => debug!("got unknown notification: {notif:?}"),
_ => debug!(notification = as_debug!(notif); "got unknown notification"),
},
}
}
Expand Down

0 comments on commit 6bb08d5

Please sign in to comment.