Return InvalidRequest if Shutdown has been requested
From the LSP 3.16 spec: "If a server receives requests after a shutdown request those requests should error with InvalidRequest."
This commit is contained in:
@@ -337,6 +337,16 @@ impl GlobalState {
|
||||
fn on_request(&mut self, request_received: Instant, req: Request) -> Result<()> {
|
||||
self.register_request(&req, request_received);
|
||||
|
||||
if self.shutdown_requested {
|
||||
self.respond(Response::new_err(
|
||||
req.id,
|
||||
lsp_server::ErrorCode::InvalidRequest as i32,
|
||||
"Shutdown already requested.".to_owned(),
|
||||
));
|
||||
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
if self.status == Status::Loading && req.method != "shutdown" {
|
||||
self.respond(lsp_server::Response::new_err(
|
||||
req.id,
|
||||
@@ -351,7 +361,10 @@ impl GlobalState {
|
||||
.on_sync::<lsp_ext::ReloadWorkspace>(|s, ()| Ok(s.fetch_workspaces()))?
|
||||
.on_sync::<lsp_ext::JoinLines>(|s, p| handlers::handle_join_lines(s.snapshot(), p))?
|
||||
.on_sync::<lsp_ext::OnEnter>(|s, p| handlers::handle_on_enter(s.snapshot(), p))?
|
||||
.on_sync::<lsp_types::request::Shutdown>(|_, ()| Ok(()))?
|
||||
.on_sync::<lsp_types::request::Shutdown>(|s, ()| {
|
||||
s.shutdown_requested = true;
|
||||
Ok(())
|
||||
})?
|
||||
.on_sync::<lsp_types::request::SelectionRangeRequest>(|s, p| {
|
||||
handlers::handle_selection_range(s.snapshot(), p)
|
||||
})?
|
||||
|
||||
Reference in New Issue
Block a user