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

Add "Restart Phan Language Server" command #103

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

blm768
Copy link

@blm768 blm768 commented Jan 22, 2022

On my Windows machine, the language server seems to run into issues regularly. Rather than implement a proper solution, I went ahead and added a command to restart the LSP server in the time-honored tradition of, "It's Windows; just restart it".

I haven't fully tested this out yet, but it seems to at least kinda work.

src/extension.ts Show resolved Hide resolved
src/extension.ts Outdated
const languageClients = analyzedProjectDirectories.map(createClient);

async function restartLanguageClients(): Promise<void> {
for (const client of languageClients) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

await Promise.all(languageClients.map(client => client.restart())) seems better, it would restart clients in parallel and restart faster

https://github.com/microsoft/vscode-languageserver-node/blob/292dd0d88b6465337e42ba40ad986fdfdeb42d4d/client/src/node/main.ts#L189-L201 as long as the languageserver dependency is new enough.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, restart doesn't seem to be in the latest version of vscode-languageserver-types. Restarting in parallel seems reasonable, though.

src/extension.ts Outdated Show resolved Hide resolved
@blm768 blm768 force-pushed the add-restart-command branch from 5912f7c to ee96b30 Compare March 1, 2022 23:09
@blm768 blm768 marked this pull request as ready for review March 1, 2022 23:10
@blm768
Copy link
Author

blm768 commented Mar 1, 2022

I don't think this is 100% perfect yet; once or twice, I've gotten an error about something having been disposed when I run the command. I haven't seen that in about a month, though, so this seems like it's probably at least good enough to be useful in its current state.

@blm768 blm768 force-pushed the add-restart-command branch from ee96b30 to 2427193 Compare November 8, 2022 00:36
This is handy when the language server crashes.
@blm768 blm768 force-pushed the add-restart-command branch from 2427193 to 2fef6f0 Compare February 6, 2023 20:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants