-
Notifications
You must be signed in to change notification settings - Fork 183
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
Adding cursors does not always trigger update of regions #1995
Comments
I encountered a similar issue when implementing inlay hints, (High chance that it is not related, i just saw the |
From the docstring of that function, it appears that this behavior is intentional: Lines 817 to 826 in 5fc0db5
And as you wrote, for some features like the DocumentHighlights this seems to make sense; it is probably only useful to show the highlights for a single cursor (the first one) at the same time, and it would be wasteful to send another request for DocumentHighlights when another cursor position after the first one is added or changes. For features which can take multiple cursor position into account (like show code actions or your diagnostics as annotations PR), it would be useful if that function returned two indicators for change of cursor positions, instead of one. For example like first_different, any_different, current_region = self._update_stored_region_async() Then the various features which are triggered on curser change, could be ordered under the relevant condition: def on_selection_modified_async(self) -> None:
first_different, any_different, current_region = self._update_stored_region_async()
if first_different:
# do DocumentHighlights
if any_different:
# do Code Actions
# do diagnostic annotations |
Also mentioned this issue in #2182 (comment) |
We now have a way to check whether any selection has changed in addition to checking whether first selection has changed so we have a choice to trigger requests on either. Some features like highlight regions, code action annotations and resolving of code lenses still only checks whether the first region has changed and could in theory result in state not being correct in some cases but it should be so rare that we can address that if there is a need. For now there is nothing more to do here really so closing. |
Describe the bug
When testing #1702 I've noticed that there is minor bug that makes us not trigger some handlers that should trigger on changing selection.
The
_update_stored_region_async
in:LSP/plugin/documents.py
Lines 379 to 381 in b117996
only checks if the first selection has changed so when adding new cursors after the existing one, the
different
is false and the handlers don't run. It works when adding new cursor before the existing one.This results in #1702 not working entirely as expected in those circumstances:
Screen.Recording.2022-07-14.at.23.45.40.mov
I haven't tried reproducing this bug with any existing feature but it seems like existing features mostly rely on a single (first) region so it probably works as expected mostly.
The text was updated successfully, but these errors were encountered: