-
Notifications
You must be signed in to change notification settings - Fork 326
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
Document diagnostics not cleared on file close when workspace diagnostics enabled #1039
Comments
Actually this is on purpose. It is assumed that workspace diagnostics is a super set of document diagnostics. Is this incorrect for you? |
Yeah, since it was recommended I should make workspace diagnostics empty for ignored files, and use document diagnostics instead: @aeschli said
in #1013 (comment), so it cannot be a superset. This makes sense to me, and it would be useful to me if this worked |
Also, if workspace diagnostics is meant to be a superset, is there any purpose in recomputing document diagnostics then? I would've assumed workspace diagnostics would then just be sufficient |
I am nit sure I understand this: why would document diagnostics be shown for ignored resource but workspace diagnostics not. Can you give me an example where this is useful? |
Our usecase: In the cases when they open an ignored file, it is useful to provide temporary diagnostics. Users normally open up these files when they are debugging things, we can therefore highlight type errors, or lint things like undefined variables. This can help them spot a problem faster when they have the file open. Once they close it, they don't want those diagnostics anymore. #848 is another issue which has the same use case |
I see the use case but this is currently not possible. I will mark it as a feature request since the tricky case here is to avoid problem flickering since the library doesn't know whether the file is ignored or not. |
Thank you for taking the time to look into this The main thing for me here is only on the "file close" (i.e. file becomes not active) event for the client.
My expectation would be that the same thing would happen regardless of whether workspaceDiagnostics capability has been enabled or not by the server. The way the client currently handles workspace vs. document diagnostics generally is not an issue (so no flickering), it is just the inconsistency when a file becomes inactive. |
There is actually more to it: when workspace diagnostics are enabled the client still send document diagnostic request to let the server know which files have priority. The assumption behind that is that workspace diagnostics is a super set of document diagnostics which is not true for your scenario. This is why this needs more work than simply clearing the diagnostics. |
@JohnnyMorganz When trying to understand the issue, I have noticed the following comment made by @dbaeumer in #1013 (comment):
Could not, then, your problem be solved by explicitly reporting an empty list of workspace diagnostics for the ignored files (regardless whether they are open or not)? It seems that, since document pull results are favoured over workspace pull results by the client, the document diagnostics will still be shown for the ignored files in the open editors, but when an ignored file gets closed, the (empty) workspace diagnostics will then replace the document diagnostics for the file. |
Aha @pisv, thank you, this seems to work! It won't work immediately though, there is one thing where you need |
@JohnnyMorganz, great to hear that! So, IIUC, the additional problem is that with workspace diagnostics there might be a delay in refreshing, but you would like the diagnostics for an ignored file be cleared immediately after the file is closed. Therefore, if the workspace diagnostics request with partial result support is still open at the moment the file is closed, you just add a partial result with empty diagnostics for the now-closed file, right? |
Yep, that is correct. Since I keep the request open for as long as possible, I can do a partial request update on the close event. [Not entirely sure if this is an antipattern though, since I'm essentially going back to pushing a diagnostic update from the server (except doing it using a partial response to a workspace pull diagnostic request). Also This works well for my use case, so I am happy to close this issue if there is nothing else that needs doing |
As far as I can tell, your implementation is in line with the specification:
and
However, I'm also a bit puzzled, because now there seems to be two ways of doing essentially the same thing -- streaming diagnostics from the server to the client -- by I also think that this issue may be closed. There seems to be no need for changes in the client, because the problem can (should?) be solved on the server side, since the language server has complete control over workspace diagnostics. @dbaeumer, can you please share your thoughts on this? |
The benefit comes with pull on documents. The old push model had no knowledge about which files to priorities. Hence it could easily happen that you saw stale errors for some time. The pull model allows to combine a long running pull with single document pulls hence knowing which once to prioritize. The solution you implemented is in line with the specification. I will close the issue. |
@dbaeumer Thank you for the clarification! |
This follows on from #1013, where it was fixed that document diagnostics are cleared when a file closed.
This works fine when a server does not support workspace diagnostics.
There, it was mentioned by @aeschli:
So I followed these steps. I implemented workspace diagnostics, and my workspace diagnostics do not follow include ignored resources - but document diagnostics do.
However, if I have workspace diagnostics enabled, the document diagnostics do not clear on file close.
I updated my pull diagnostics minimal repro (https://github.com/JohnnyMorganz/pull-diagnostics-bug) with the following diff:
The text was updated successfully, but these errors were encountered: