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

Handle unicode uppercase characters in autocomplete #990

Closed
vinistock opened this issue Sep 8, 2023 · 5 comments
Closed

Handle unicode uppercase characters in autocomplete #990

vinistock opened this issue Sep 8, 2023 · 5 comments
Labels
enhancement New feature or request pinned This issue or pull request is pinned and won't be marked as stale

Comments

@vinistock
Copy link
Member

See #957 (comment) for more context.

We currently only support "A".."Z" for completion. Let's understand the efforts and trade offs for supporting any arbitrary uppercase unicode character for completion, since Ruby does allow them to be used in constant names.

@vinistock vinistock added the enhancement New feature or request label Sep 8, 2023
@vinistock vinistock added this to the 2023-Q3 milestone Sep 8, 2023
@kddnewton
Copy link
Contributor

The characters that can begin constants depends on the source encoding. If it's # encoding: ascii then what you have is correct. So whatever solution you end up with, you should use the encoding of the source file.

A cheap way to do it is to ask Ripper or YARP. Both will have the encoding object for you.

encoding = Ripper.new(source).tap(&:parse).encoding

Once you have the encoding, you should make a regexp that is fixed so that encoding:

regexp = Regexp.new("[[:upper:]]".encode(encoding), Regexp::FIXEDENCODING)

then you can check if it matches the character:

begin
  regexp.match?(character)
rescue Encoding::CompatibilityError
  # If the character can't be represented in that encoding, then
  # it can't possibly be uppercase.
  false
end

@kddnewton
Copy link
Contributor

@nirvdrum would know much more about this

@vinistock
Copy link
Member Author

@paracycle found out the right answer in #1171 (comment). The spec already handles any valid identifier for trigger characters, so we actually don't have to worry about this.

Just indexing constants that use unicode characters should be enough.

Copy link
Contributor

github-actions bot commented Jan 9, 2024

This issue is being marked as stale because there was no activity in the last 2 months

@github-actions github-actions bot added the Stale label Jan 9, 2024
@vinistock vinistock added pinned This issue or pull request is pinned and won't be marked as stale and removed Stale labels Jan 9, 2024
@vinistock
Copy link
Member Author

Honestly, this doesn't feel like it's worth the effort and we received no requests for supporting this.

@vinistock vinistock closed this as not planned Won't fix, can't repro, duplicate, stale Aug 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request pinned This issue or pull request is pinned and won't be marked as stale
Projects
None yet
Development

No branches or pull requests

2 participants