-
Notifications
You must be signed in to change notification settings - Fork 65
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
Shutdown the server on shutdown
request using connection.handle_shutdown
.
#195
Conversation
shutdown
request using `connection.handle_shutdown.shutdown
request using connection.handle_shutdown
.
I wrote a comment on the MR, but overall looks ok. I see the CI fails, it is because github upgraded the rust version which introduces new cargo fmt and clippy errors. I fixed those on master so you could rebase on master to get green branch. |
90bb766
to
8d3da8c
Compare
Hello, sorry for the delay, I somehow missed the comment. Unfortunately, I do not see your comment on the MR. I rebased onto master. |
vhdl_ls/src/stdio_server.rs
Outdated
Err(err) => panic!("{err:?}") | ||
} | ||
|
||
self.handle_request(&mut server, request) |
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.
Should this code be in the else-branch of the if shutdown
above?
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.
Yeah, that seems better than the current solution. I have removed the break; and added else-branch with handle_request. Is this okay from your side? I have tested this in emacs and works okay, doesn't err on shutdown as it did before.
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.
Looks good
I forgot to publish the comment. Now it is published. |
8d3da8c
to
4728119
Compare
Should I write a unit test that would send |
4728119
to
a1eef68
Compare
Sorry, forgot to run fmt 🤦♂️, I always forget. |
I do not think a unit test is necessary in this codebase. Since the deserialization of JSON RPC messages is handled by a third party library. It would be up to this library to support every legal shutdown request format (or be tolerant to slightly malformed messages). |
I noticed in an example in rust-analyzer repository: https://github.com/rust-lang/rust-analyzer/blob/master/lib/lsp-server/examples/goto_def.rs#L86C31-L86C46 that there is a handle_shutdown method that does a little more than what vhdl_ls currently did. Using this method also fixes #194 thanks to not actually deserializing the request - so it kind of works around the problem, so probably not the best solution.
It looks like the parameters of the shutdown request that are sent are:
{}
, this gets parsed into Map instead of unit -()
.