-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
feat: lsp-restart #533
Conversation
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(); |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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).
closes #523