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

feat: lsp-restart #533

Closed
wants to merge 2 commits into from
Closed

feat: lsp-restart #533

wants to merge 2 commits into from

Conversation

gbaranski
Copy link
Contributor

closes #523

@gbaranski
Copy link
Contributor Author

Even after replacing languague_server with a new one, it still reports "Async job failed: channel closed", did I forgot to do something?

}
let callback: job::Callback = Box::new(move |editor: &mut Editor, _compositor| {
let doc = editor.document(doc_id).unwrap();
let language_config = doc.language_config_arc().unwrap();
Copy link
Member

Choose a reason for hiding this comment

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

No need for an arc here.

let callback: job::Callback = Box::new(move |editor: &mut Editor, _compositor| {
let doc = editor.document(doc_id).unwrap();
let language_config = doc.language_config_arc().unwrap();
let language_server = editor.language_servers.get(&language_config).unwrap();
Copy link
Member

Choose a reason for hiding this comment

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

You're getting the failures because language_servers.get() returns the same server you just shut down. We maintain one server instance per language because it's shared across files. I think what you really want to do is add a language_server.restart() method that will do this inside the server.

It's hard to get mutable access though, so I imagine we actually want to use arc-swap here to start a new server, arc-swap the new server in. It's a bit trickier than that, you also need to loop over all the documents and re-send textDocument/open events for all open files with that language server, as well as replay any changes since last file save (you can do this by taking the last saved version id, then replaying all the changes in the tree from that id to current id).

This pull request was closed.
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.

add :lsp-restart command
2 participants