diff --git a/src/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/AbstractLanguageServer.cs b/src/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/AbstractLanguageServer.cs index 89f6d1b0f1aa0..8dfaaf906cac6 100644 --- a/src/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/AbstractLanguageServer.cs +++ b/src/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/AbstractLanguageServer.cs @@ -65,6 +65,9 @@ protected AbstractLanguageServer( _jsonRpc = jsonRpc; TypeRefResolver = typeRefResolver ?? TypeRef.DefaultResolver.Instance; + // We have no need to continue running LSP requests after the connection is closed. + _jsonRpc.CancelLocallyInvokedMethodsWhenConnectionIsClosed = true; + _jsonRpc.AddLocalRpcTarget(this); _jsonRpc.Disconnected += JsonRpc_Disconnected; _lspServices = new Lazy(() => ConstructLspServices());