-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Avoid resetting the code completion popup excessively #81633
Conversation
Yeah, that's fine. But when you do, please make sure to use a commit message that follows the project's style. The current title of this PR is a good option. |
0235362
to
2735aec
Compare
Squashed commits and addressed feedback |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution!
Looks great with test as well, couple small comments left inline
2735aec
to
303d099
Compare
Addressed Feedback |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thanks! And congrats for your first merged Godot contribution 🎉 |
Fixes #57027. The issue was that
_filter_code_completion_candidates_impl
always resets the selected item. While up/down won't cause an update, there is a race condition where updating the list and then quickly changing selection will cause the selection to move and then reset. This can also happen even when the update doesn't actually change the list of options.The fix here was to have
_filter_code_completion_candidates_impl
check to see if the new options list is the same up to the currently selected item. Then we only reset the selection if the list differs before the selection. That way if the list only changes after the selection we won't reset. If the list changes before our selection, then we still want to reset as the selected item may no longer be meaningful.This is done by building a new list and then comparing. There is an increased memory footprint in that we must hold two lists while doing the update, but once we are done we discard the old list. There is also a time increase in that we need to perform the list comparison (copying over the new list should be the same as clearing the old list and building the new one like we did originally). Considering that this lists will typically be small the time and memory hit should be unnoticeable from a UX standpoint.
I also implemented it for the overridden version but I wasn't sure how to test that directly. But the tests for the non-overridden version should check the base logic. I am not 100% sure how this override system works so any notes and explanation would be appreciated.
I haven't squashed yet, but figured I was going to have to make some updates in the review anyway so will squash after the notes.