Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workaround for terminal PID freeze #2498

Merged
merged 2 commits into from
Feb 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions src/process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,21 +110,25 @@ export class PowerShellProcess {
hideFromUser: !this.sessionSettings.integratedConsole.showOnStartup,
});

const pwshName = path.basename(this.exePath);
this.log.write(`${pwshName} started.`);

if (this.sessionSettings.integratedConsole.showOnStartup) {
// We still need to run this to set the active terminal to the Integrated Console.
this.consoleTerminal.show(true);
}

// Start the language client
this.log.write("Waiting for session file");
const sessionDetails = await this.waitForSessionFile();

// Subscribe a log event for when the terminal closes
this.log.write("Registering terminal close callback");
this.consoleCloseSubscription = vscode.window.onDidCloseTerminal((terminal) => this.onTerminalClose(terminal));

// Log that the PowerShell terminal process has been started
const terminalPid = await this.consoleTerminal.processId;
const pwshName = path.basename(this.exePath);
this.log.write(`${pwshName} started, pid: ${terminalPid}`);
this.log.write("Registering terminal PID log callback");
this.consoleTerminal.processId.then((pid) => this.logTerminalPid(pid, pwshName));

return sessionDetails;
}
Expand Down Expand Up @@ -152,6 +156,10 @@ export class PowerShellProcess {
}
}

private logTerminalPid(pid: number, exeName: string) {
this.log.write(`${exeName} PID: ${pid}`);
}

private isLoginShell(pwshPath: string): boolean {
try {
// We can't know what version of PowerShell we have without running it
Expand All @@ -172,9 +180,11 @@ export class PowerShellProcess {
utils.deleteSessionFile(this.sessionFilePath);

if (error) {
this.log.write("Error occurred retrieving session file");
return reject(error);
}

this.log.write("Session file found");
resolve(sessionDetails);
});
});
Expand Down
6 changes: 5 additions & 1 deletion src/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,11 @@ export class SessionManager implements Middleware {
this.log.write("Language server startup failed.");
this.setSessionFailure("The language service could not be started: ", error);
},
);
)
.catch((error) => {
this.log.write("Language server startup failed.");
this.setSessionFailure("The language server could not be started: ", error);
});
}

private promptForRestart() {
Expand Down