-
Notifications
You must be signed in to change notification settings - Fork 188
Limit semantic highlighting to single session again #2715
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
Conversation
The code block at https://github.com/sublimelsp/LSP/pull/2715/changes#diff-982c110867d9809c978a5597e4da66ce7538b327675a66b8f27214413b7c0ec1R267-R270 that you have re-added here should make that semantic highlighting from a previous session is cleared whenever another session, which is considered as the new "best" session, initializes. So there should only ever be semantic tokens be rendered from a single session, even if they were also requested previously from another session. The reason why you still see them in the scope name popup is because internally the token data itself is still stored in a variable per SessionBuffer when you query that in LSP/plugin/semantic_highlighting.py Lines 84 to 87 in 1ae02ea
That data might even become outdated after some more buffer changes, when the new requests only go to one of the sessions, so I think this needs to be fixed. If we revert that to use the |
|
I've just realized something. Screen.Recording.2025-12-12.at.15.11.48.movPerhaps it would be best to iterate over all sessions but ensure that tokens are cleared properly when session is no longer considered "best". |
Yes, I've realized the same previously in my PR and set the position offset to 0 in 8e034b0 to ensure a stable session. Here you found another place that I have missed in that PR. So you can just pass 0 to the |
Before I saw your comment I've come up with a solution where I clear pending requests on canceling semantic tokens (there was a timing issue where Also as far as formatting in popup feel free to provide better suggestion or even just push changes but since technically it's a list of tokens again, it's harder to say where the session name should be. |
|
Setting the offset to 0 is the right thing to do IMO because the semantic tokens are requested for the entire file anyway. Using the cursor position makes sense for things like "Goto definition" where different parts of the file might be handled by different sessions. I would revert the last commit and keep clearing the rendering separate from the data handling. The previous semantic tokens data needs to be used for the delta requests, and I think we can still make use of that even after a request got cancelled (at least in theory - I haven't checked if that case could happen in practice). |
This reverts commit 04db4b1.
|
Without something like Lines 794 to 795 in 04db4b1
Lines 268 to 270 in ee8ed86
(which happens to be the case for me with LSP-vue & LSP-typescript combo). |
Okay, good observation. Then I would add it under the if request_id := sb.semantic_tokens.pending_response:
sb.session.cancel_request_async(request_id) |
Since I've looked more into LSP-vue now, I've realized that my revert in #2711 wasn't really needed and the issue was that the priority_selector was wrong and to get proper semantic highlighting it's enough to request tokens from the vue server rather than from both vue and typescript server.
So bring back code that limits semantic highlight request to just one server. This is fine together with the sublimelsp/LSP-vue#166 change in LSP-vue.
I have not reverted other changes that I made in my previous PR (code consolidation, scope popup changes etc). Also I've noticed that due to timing we still can end up requesting semantic tokens from both sessions if LSP-typescript starts first so it makes sense that in the scope popup we still don't limit anything to single session.