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

[lsp-restart]: call the force_shutdown method for the old_client #3972

Merged
merged 3 commits into from
Oct 3, 2022
Merged
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
6 changes: 5 additions & 1 deletion helix-lsp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,11 @@ impl Registry {
let NewClientResult(client, incoming) = start_client(id, language_config, config)?;
self.incoming.push(UnboundedReceiverStream::new(incoming));

entry.insert((id, client.clone()));
let (_, old_client) = entry.insert((id, client.clone()));

tokio::spawn(async move {
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder if we could add this to the Drop implementation instead on the server I guess?

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't have a way of replicating this unfortunately, but what I'm thinking is that if you impl Drop for the client, then you could just call shutdown_and_exist, then print something if needed. This approach may also solve #3482

Copy link
Contributor Author

@axdank axdank Sep 26, 2022

Choose a reason for hiding this comment

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

When trying to implement the drop trait in the Client to call the shutdown method, I always have the problem of needing a lifetime of type 'static because self has an anonymous lifetime. 😫

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the main issue there it's shutdown is async, I'll take a look at thsi when I have some time. This is also not a blocker, was just an improvement for better encapsulation IMO

let _ = old_client.force_shutdown().await;
});

Ok(Some(client))
}
Expand Down