on master help sign in
LSP: Forcefully shutdown uninitialized servers (#7449)
e0bb032Michael Davis
helix-lsp/src/transport.rs+9−1
@@ -353,6 +353,11 @@ impl Transport {
353 }
353 }
354 }
354 }
355
355
356+ fn is_shutdown(payload: &Payload) -> bool {
357+ use lsp_types::request::{Request, Shutdown};
358+ matches!(payload, Payload::Request { value: jsonrpc::MethodCall { method, .. }, .. } if method == Shutdown::METHOD)
359+ }
360+
356 // TODO: events that use capabilities need to do the right thing
361 // TODO: events that use capabilities need to do the right thing
357
362
358 loop {
363 loop {
@@ -391,7 +396,10 @@ impl Transport {
391 }
396 }
392 msg = client_rx.recv() => {
397 msg = client_rx.recv() => {
393 if let Some(msg) = msg {
398 if let Some(msg) = msg {
399+ if is_pending && is_shutdown(&msg) {
400+ log::info!("Language server not initialized, shutting down");
401+ break;
394− if is_pending && !is_initialize(&msg) {
402+ } else if is_pending && !is_initialize(&msg) {
395 // ignore notifications
403 // ignore notifications
396 if let Payload::Notification(_) = msg {
404 if let Payload::Notification(_) = msg {
397 continue;
405 continue;