-
Notifications
You must be signed in to change notification settings - Fork 201
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
Still shows diagnostics on closed files #143
Comments
Indeed the LSP specification says that:
For the other part however:
I don't think this is the server issue; it does not know anything about the panel; I would recommend going back to sublimelsp with this one. |
@krassowski, would you mind responding to @rwols on the LSP issue? I'm just a user that doesn't know what any of this means and don't want to confuse things. |
I don't believe there is anything to respond - the interface behaviour like moving diagnostic panel is just an unrelated issue, and I think you are in much better position to open a new issue about it than myself as I do not use sublime ;) |
@krassowski, I don't understand what we should do to clear diagnostics on our side. Perhaps cancelling all pending requests for a file after it's closed? |
My understanding is that when we receive |
This is a similar pattern to the server notifying the client about the need to close signature hover by sending |
Looking further into this, the specification does not have a detailed normative text on it, just an example of how VSCode handles it:
My understanding is that the differences are on client level: if client supports "projects", it will "open" all files with the server and not send the close notification (unless file is deleted); if the file is not part of the project, it the client will only open the file when it actually gets open and send "close" notification as soon as the files is actually closed in the user interface. This seems to be to allow to show diagnostics for all files even if only one or few are actually open in the main editing area (e.g. to highlight files with errors). |
Haven't seen such behavior in any client. Especially not in VSCode which can be seen as a "reference" implementation. Some servers just clear the diagnostics after As far as I understand it, the servers can be divided into those that handle "projects" (for example clang) and those that don't have a concept of projects and work on individual files instead (for example JSON server). So then it's the choice of the server whether it wants to clear the diagnostics on closing a file or not but with that in mind, I would expect the JSON server to clear the diagnostics on closing a file while I would not necessarily expect the clang server to do that. But in the end it's still a choice the server has to make and I'm not sure which behavior is more correct for the pylsp server. It's not unlikely that changing the behavior will result in some other person complaining that he/she liked the previous behavior. |
Do you depend on the server clearing diagnostics to clear them also from the Sublime panel that shows them? If that's the case, we can make the change here (even if not mandatory) to make things easier for you. I agree that perhaps other clients don't expect that, but (to me) it's a simple change so they could adapt to it. |
Yes, the ST panel only shows the diagnostics that the server has reported and hasn't cleared. But I don't think this is in any way specific to ST. VSCode would do the same in its Problems panel. |
I don't anything is ever cleared presently, so I don't think there'd be complaints between file/project people in any case. If things were cleared, I'd prefer the diagnostics only show for currently open files. |
Not sure what you mean. pylsp diagnostics of closed files are not currently cleared in ST but that's because pylsp doesn't clear them. If it would then ST would clear them also. |
FWIW, https://github.com/microsoft/pyright for example has a setting for this:
If a server chooses not to clear diagnostics after |
Hey @reagle, @rchl and @jwortmann, I created PR #165 to fix this. Could you apply that small change to your local installations of this project and check if it solves the problem for you? I'm almost sure it will, but I'd just like your help to be extra confident about it. |
Thanks for doing this! This is beyond me at the moment, though, as I know nothing about LSP other than it is a package that is installed. Hopefully someone else can test it. |
I've got around to testing it and it works as advertised. |
Great! Thanks for your help with that @rchl. |
As first documented in sublimelsp/LSP#1925, when I close a file, its diagnostics continue to pollute the diagnostic panel until I exit ST. This unfortunately obscures any problems I might have in the python files that I keep linted. (Similarly, it'd be nice if the diagnostic panel view moved to the start of the diagnostics for the current visible pane/tab.)
Open a file with many diagnostics.
Close the file and the diagnostics persist.
macOS 12.1 21C52 arm64 using ST 4126 with LSP 1.15.0 and LSP-pylsp 2.3.1.
The text was updated successfully, but these errors were encountered: