Skip to content
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

Use shortest possible constant name for filtering completions #1074

Merged
merged 1 commit into from
Oct 13, 2023

Conversation

vinistock
Copy link
Member

Motivation

I noticed that completion suggestions using non-qualified constant names were getting poorly ranked in the list. The reason is because we were always using the fully qualified name as the filter text.

For example

module Foo
  module Bar
    class Baz
    end

    # Triggering completion here would compare `B` against `Foo::Bar::Baz`, which makes
    # it rank poorly. In reality, we should be comparing it to `Baz` since it's inside
    # the same namespace
    B
  end
end

Implementation

Used the same idea as our insertion text - deleting all parts of the current nesting to find the shortest possible name for the constant. The only catch in this case is that we only want to do that if the user is not explicitly typing the fully qualified name of the constant - in which case we do want the filter text to include the namespaces.

Automated Tests

Added a test showing the desired behaviour.

@vinistock vinistock added the enhancement New feature or request label Oct 10, 2023
@vinistock vinistock added this to the 2023-Q3 milestone Oct 10, 2023
@vinistock vinistock requested a review from a team as a code owner October 10, 2023 15:30
@vinistock vinistock self-assigned this Oct 10, 2023
Copy link
Contributor

@andyw8 andyw8 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will need an update since HAS_TYPECHECKER was removed in #1042.

@vinistock vinistock force-pushed the vs/use_short_name_for_filtering branch from 73c6bfc to 33433c1 Compare October 12, 2023 16:58
@vinistock vinistock requested a review from andyw8 October 12, 2023 16:58
@vinistock
Copy link
Member Author

Updated all the places that weren't using the stub in the completion test.

@vinistock vinistock force-pushed the vs/use_short_name_for_filtering branch from 33433c1 to 452bc49 Compare October 13, 2023 19:23
@vinistock vinistock enabled auto-merge (squash) October 13, 2023 19:32
@vinistock vinistock merged commit 87be915 into main Oct 13, 2023
28 of 30 checks passed
@vinistock vinistock deleted the vs/use_short_name_for_filtering branch October 13, 2023 19:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants