Fix LSP status field missing randomly #1901
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The status fields for indicating that the server is running would sometimes not be shown. This has happened randomly when sessions were initializing.
The issue was that the view settings listener set up in
DocumentViewListener
would always trigger initially since we didn't initializeself._current_syntax
from__init__
so the check if something has changed would evaluate toTrue
and callself._reset()
.At the point the
self._reset()
is called theSessionViews
might already have been created (and in fact almost always are since the settings change is triggered by us adding new keys on starting the session) and the reset call will result in those being destroyed and newSessionViews
created.Now, this doesn't fix the root issue. I think the root issue is the fact that the
SessionView.__del__
of those cleared instances can get called after the newSessionView
s are created thus resulting in the old one erasing the view status set by the new one.As nice as relying on
__del__
might seem, I think it would be better to have explicit public methods for clearing the state and not relying on__del__
in general since it's not really guaranteed when those will run.The fix ensures that we don't unnecessarily reset the sessions and trigger this issue on start.