-
Notifications
You must be signed in to change notification settings - Fork 156
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 showing duplicate completions #2215
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vinistock
added
bugfix
This PR will fix an existing bug
server
This pull request should be included in the server gem's release notes
labels
Jun 20, 2024
vinistock
changed the title
Vs/avoid showing duplicate completions
Avoid showing duplicate completions
Jun 20, 2024
st0012
reviewed
Jun 20, 2024
vinistock
force-pushed
the
vs/avoid_showing_duplicate_completions
branch
from
June 21, 2024 13:47
691e113
to
6bc29fc
Compare
Morriar
reviewed
Jun 21, 2024
st0012
reviewed
Jun 21, 2024
vinistock
force-pushed
the
vs/avoid_showing_duplicate_completions
branch
from
June 21, 2024 15:16
6bc29fc
to
7c7823f
Compare
st0012
approved these changes
Jun 21, 2024
Morriar
reviewed
Jun 21, 2024
vinistock
force-pushed
the
vs/avoid_showing_duplicate_completions
branch
from
June 21, 2024 16:42
7c7823f
to
6185828
Compare
Morriar
reviewed
Jun 21, 2024
def owner | ||
@target.owner | ||
end | ||
# sig { returns(T.nilable(Entry::Namespace)) } |
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.
Was this change intentional?
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.
Ah, forgot to remove the commented out code. I removed it directly on main 3aa0430.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Motivation
While testing #2214, I noticed we were showing duplicate completion entries. The issue is that we were not deduping methods with the same name that appear multiple times in the same hierarchy chain.
We always want to show only the first entry we find in the hierarchy chain, since that's the one that is actually getting invoked.
Implementation
Since the prefix search returns all possible methods with no ordering guarantees, I started using a hash to remember the entries we found and the index in the ancestor chain where we found it.
Then we only override the entries if we find one earlier in the chain.
The code has a little bit of duplication, but it's hard to avoid because the completion path triggered on the dot character (
@entries.values.flatten
) returns any type of entries included classes. We can either duplicate the entry class checks or the ancestor index checks, but I don't think we can fully remove all of the duplication.Automated Tests
Added a test that prevents regression.