Force shutdown when received from the client, #1

This commit is contained in:
Paulo Aboim Pinto 2022-04-07 02:00:26 +02:00
Родитель b2ff44ad88
Коммит 871d7580af
2 изменённых файлов: 29 добавлений и 19 удалений

Просмотреть файл

@ -24,23 +24,26 @@ namespace Avalonia.axamlLanguageServer
Log.Logger.Information("Starting log...");
var server = await OmniSharp.Extensions.LanguageServer.Server.LanguageServer
.From(
options =>
options
.WithInput(Console.OpenStandardInput())
.WithOutput(Console.OpenStandardOutput())
.ConfigureLogging(
x => x
.AddSerilog(Log.Logger)
.AddLanguageProtocolLogging()
.SetMinimumLevel(LogLevel.Debug)
)
.WithServices(ConfigureServices)
.WithHandler<TextDocumentHandler>()
.WithHandler<FileChangeHandler>()
.WithHandler<AvaloniaCodeCompletionHandler>())
.ConfigureAwait(false);
var server = await LanguageServer.From(
options => options
.WithInput(Console.OpenStandardInput())
.WithOutput(Console.OpenStandardOutput())
.ConfigureLogging(
x => x
.AddSerilog(Log.Logger)
.AddLanguageProtocolLogging()
.SetMinimumLevel(LogLevel.Debug)
)
.WithServices(ConfigureServices)
.WithHandler<TextDocumentHandler>()
.WithHandler<FileChangeHandler>()
.WithHandler<AvaloniaCodeCompletionHandler>()
).ConfigureAwait(false);
server.Shutdown.Subscribe(x => {
Log.Logger.Information("--> Shutdown...");
Environment.Exit(0);
});
await server
.WaitForExit

Просмотреть файл

@ -4,8 +4,8 @@ import { workspace } from 'vscode';
import {
LanguageClient,
LanguageClientOptions,
ServerOptions,
LanguageClientOptions,
TransportKind,
} from "vscode-languageclient/node";
@ -62,4 +62,11 @@ export function activate(context: vscode.ExtensionContext) {
}
export function deactivate() {}
export function deactivate() : Thenable<void> | undefined
{
if (!client) {
return undefined;
}
return client.stop();
}