Skip to content

Commit

Permalink
fix - Register the waitForImporterPipePath promise earlier (#1573)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jiaaming authored Aug 9, 2024
1 parent 5ff06bb commit 93e6886
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions extension/src/bs/JdtlsImporterConnector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export class JdtlsImporterConnector {
private importerConnection: rpc.MessageConnection | null = null;
private importerPipeServer: net.Server;
private importerPipePath: string;
private setPipePathPromise: Promise<void> | null = null;
private readonly _onImporterReady: vscode.EventEmitter<string> = new vscode.EventEmitter<string>();

constructor(private readonly context: vscode.ExtensionContext) {
Expand All @@ -28,7 +29,14 @@ export class JdtlsImporterConnector {
* @returns Promise that resolves when the pipe path is ready
*/
public async waitForImporterPipePath(): Promise<void> {
return new Promise((resolve) => {
await this.setPipePathPromise;
}

/**
* The `_onPipePathReady` event will be fired when the pipe path is received from Java jdt.ls importer
*/
private registerCommand(): void {
this.setPipePathPromise = new Promise((resolve) => {
this._onImporterReady.event((resolvedPath) => {
this.importerPipePath = resolvedPath;
sendInfo("", {
Expand All @@ -37,12 +45,6 @@ export class JdtlsImporterConnector {
resolve();
});
});
}

/**
* The `_onPipePathReady` event will be fired when the pipe path is received from Java jdt.ls importer
*/
private registerCommand(): void {
this.context.subscriptions.push(
vscode.commands.registerCommand(ON_WILL_IMPORTER_CONNECT, (pipeName: string) => {
this._onImporterReady.fire(path.resolve(pipeName));
Expand Down

0 comments on commit 93e6886

Please sign in to comment.