Skip to content

Commit 9b6046e

Browse files
authored
Fix moving refactoring not working in standard mode (#2506)
* Fix moving refactoring not working in standard mode - return the 'stop()' promise in each 'xxxClient.stop()' method. - return 'Promise.all()' in 'deactivate()' Signed-off-by: sheche <sheche@microsoft.com>
1 parent 4d954f7 commit 9b6046e

3 files changed

Lines changed: 21 additions & 17 deletions

File tree

src/extension.ts

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -427,9 +427,7 @@ export function activate(context: ExtensionContext): Promise<ExtensionAPI> {
427427

428428
apiManager.getApiInstance().onDidServerModeChange((event: ServerMode) => {
429429
if (event === ServerMode.STANDARD) {
430-
syntaxClient.getClient().stop().then(client => {
431-
syntaxClient.stop();
432-
});
430+
syntaxClient.stop();
433431
fileEventHandler.setServerStatus(true);
434432
runtimeStatusBarProvider.initialize(context);
435433
}
@@ -635,16 +633,11 @@ export function getJavaConfig(javaHome: string) {
635633
return javaConfig;
636634
}
637635

638-
export function deactivate(): Promise<void> {
639-
return getActiveLanguageClient().then(client => {
640-
standardClient.stop();
641-
syntaxClient.stop();
642-
if (!client) {
643-
return undefined;
644-
} else {
645-
return client.stop();
646-
}
647-
});
636+
export function deactivate(): Promise<void[]> {
637+
return Promise.all<void>([
638+
standardClient.stop(),
639+
syntaxClient.stop(),
640+
]);
648641
}
649642

650643
export async function getActiveLanguageClient(): Promise<LanguageClient | undefined> {

src/standardLanguageClient.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -518,10 +518,16 @@ export class StandardLanguageClient {
518518
}
519519
}
520520

521-
public stop() {
521+
public stop(): Promise<void> {
522+
this.status = ClientStatus.Stopping;
522523
if (this.languageClient) {
523-
this.status = ClientStatus.Stopping;
524+
try {
525+
return this.languageClient.stop();
526+
} finally {
527+
this.languageClient = null;
528+
}
524529
}
530+
return Promise.resolve();
525531
}
526532

527533
public getClient(): LanguageClient {

src/syntaxLanguageClient.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,16 @@ export class SyntaxLanguageClient {
8989
}
9090
}
9191

92-
public stop() {
92+
public stop(): Promise<void> {
9393
this.status = ClientStatus.Stopping;
9494
if (this.languageClient) {
95-
this.languageClient = null;
95+
try {
96+
return this.languageClient.stop();
97+
} finally {
98+
this.languageClient = null;
99+
}
96100
}
101+
return Promise.resolve();
97102
}
98103

99104
public isAlive(): boolean {

0 commit comments

Comments
 (0)