Skip to content

Commit 6d897c8

Browse files
committed
Fix PowerShellProcess.dipose() to fire the onExited event
It was only firing when the terminal was closed, not whenever the process exited (which didn't make sense given its name and how we were using it). Also had to be idempotent.
1 parent 2397932 commit 6d897c8

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/process.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export class PowerShellProcess {
1515
private static warnUserThreshold = 30;
1616

1717
public onExited: vscode.Event<void>;
18-
private onExitedEmitter = new vscode.EventEmitter<void>();
18+
private onExitedEmitter?: vscode.EventEmitter<void>;
1919

2020
private consoleTerminal?: vscode.Terminal;
2121
private consoleCloseSubscription?: vscode.Disposable;
@@ -31,6 +31,7 @@ export class PowerShellProcess {
3131
private sessionFilePath: vscode.Uri,
3232
private sessionSettings: Settings) {
3333

34+
this.onExitedEmitter = new vscode.EventEmitter<void>();
3435
this.onExited = this.onExitedEmitter.event;
3536
}
3637

@@ -149,6 +150,9 @@ export class PowerShellProcess {
149150

150151
void this.deleteSessionFile(this.sessionFilePath);
151152

153+
this.onExitedEmitter?.fire();
154+
this.onExitedEmitter = undefined;
155+
152156
this.consoleTerminal?.dispose();
153157
this.consoleTerminal = undefined;
154158

@@ -230,7 +234,6 @@ export class PowerShellProcess {
230234
}
231235

232236
this.logger.writeWarning(`PowerShell process terminated or Extension Terminal was closed, PID: ${this.pid}`);
233-
this.onExitedEmitter.fire();
234237
this.dispose();
235238
}
236239
}

src/session.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -530,13 +530,13 @@ export class SessionManager implements Middleware {
530530
this.sessionSettings);
531531

532532
languageServerProcess.onExited(
533-
async () => {
533+
() => {
534534
LanguageClientConsumer.onLanguageClientExited();
535535

536536
if (this.sessionStatus === SessionStatus.Running
537537
|| this.sessionStatus === SessionStatus.Busy) {
538538
this.setSessionStatus("Session Exited!", SessionStatus.Failed);
539-
await this.promptForRestart();
539+
void this.promptForRestart();
540540
}
541541
});
542542

0 commit comments

Comments
 (0)