Skip to content

Commit 6c97673

Browse files
yaohaizhfbricon
authored andcommitted
Allow max 5 seconds for server to shutdown. (#628)
Signed-off-by: Yaohai Zheng <yaozheng@microsoft.com>
1 parent 7887ef6 commit 6c97673

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

src/extension.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { StatusNotification, ClassFileContentsRequest, ProjectConfigurationUpdat
1313

1414
let oldConfig;
1515
let lastStatus;
16+
let languageClient : LanguageClient;
1617

1718
export function activate(context: ExtensionContext) {
1819

@@ -85,7 +86,7 @@ export function activate(context: ExtensionContext) {
8586
}
8687

8788
// Create the language client and start the client.
88-
let languageClient = new LanguageClient('java', 'Language Support for Java', serverOptions, clientOptions);
89+
languageClient = new LanguageClient('java', 'Language Support for Java', serverOptions, clientOptions);
8990
languageClient.registerProposedFeatures();
9091
languageClient.onReady().then(() => {
9192
languageClient.onNotification(StatusNotification.type, (report) => {
@@ -235,23 +236,27 @@ export function activate(context: ExtensionContext) {
235236
};
236237
workspace.registerTextDocumentContentProvider('jdt', provider);
237238
});
238-
let disposable = languageClient.start();
239+
languageClient.start();
239240
// Register commands here to make it available even when the language client fails
240241
commands.registerCommand(Commands.OPEN_SERVER_LOG, () => openServerLogFile(workspacePath));
241242

242243
let extensionPath = context.extensionPath;
243244
commands.registerCommand(Commands.OPEN_FORMATTER, async () => openFormatter(extensionPath));
244245

245-
// Push the disposable to the context's subscriptions so that the
246-
// client can be deactivated on extension deactivation
247-
context.subscriptions.push(disposable);
248246
context.subscriptions.push(onConfigurationChange());
249247
toggleItem(window.activeTextEditor, item);
250248
});
251249
});
252250
});
253251
}
254252

253+
export function deactivate(): Thenable<void> {
254+
if (!languageClient) {
255+
return undefined;
256+
}
257+
return languageClient.stop();
258+
}
259+
255260
function enableJavadocSymbols() {
256261
// Let's enable Javadoc symbols autocompletion, shamelessly copied from MIT licensed code at
257262
// https://github.com/Microsoft/vscode/blob/9d611d4dfd5a4a101b5201b8c9e21af97f06e7a7/extensions/typescript/src/typescriptMain.ts#L186

0 commit comments

Comments
 (0)