-
Notifications
You must be signed in to change notification settings - Fork 171
add version support to textDocument/publishDiagnostics #1382
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
base: main
Are you sure you want to change the base?
Conversation
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.
Thanks for contributing! A few tests for this behavior would make us confident it works really well.
Could you add some tests in the lsp_interaction folder where each version for a diagnostics response is correct?
Thanks!!
| } | ||
| self.connection.publish_diagnostics(diags); | ||
| self.connection | ||
| .publish_diagnostics(diags, &*self.version_info.lock()); |
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.
nit: by aqcuiring the lock here, we won't be able to make updates to the version info. maybe we should clone it instead?
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.
cloning the hashtable might be kind of heavy too? I prefer lock. let me know if otherwise.
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.
publish_diagnostics_for_uri takes an i32 so maybe we can change the API to only call these functions with that?
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.
I'm not sure I follow you, publish_diagnostics_for_uri takes an Option<i32> as version, also the change API part.
7028101 to
77eb1c0
Compare
I added a small test for this, however I can't figure out why it won't work, might need a little help here. : ( |
50c3750 to
9313fb2
Compare
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.
could you paste the test failure? it should show the messages back/forth.
| } | ||
| self.connection.publish_diagnostics(diags); | ||
| self.connection | ||
| .publish_diagnostics(diags, &*self.version_info.lock()); |
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.
publish_diagnostics_for_uri takes an i32 so maybe we can change the API to only call these functions with that?
| .client | ||
| .expect_message(lsp_server::Message::Notification( | ||
| lsp_server::Notification { | ||
| method: "textDocument/publishDiagnostics".to_owned(), |
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.
if we send a server.diagnostic request we should receive a document diagnostic response (maybe we also get a publishDiagnostic)
| )); | ||
|
|
||
| interaction.server.did_change("text_document.py", "# test"); | ||
| interaction.server.diagnostic("text_document.py"); |
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.
we likely can skip these diagnostic requests since the server always publishes diagnostics regardless of the client asking for them
|
hmm that test looks like the behavior you want. like the other comments say, you're looking for the publishDiagnostic notification, not the textDocument/diagnostic response. the first one happens because of the type error then the next one happens because of the didChange. you can remove the document diagnostic requests and make a similar method to |
f982a09 to
32c4548
Compare
Now the test always fails with Timeout error, idk why. |
close #794
PS: I know little about LSP or this project