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

Decode for better readability #1092

Merged
merged 1 commit into from Nov 29, 2019
Merged

Decode for better readability #1092

merged 1 commit into from Nov 29, 2019

Conversation

@ckipp01
Copy link
Member

ckipp01 commented Nov 29, 2019

When I first came across this I found it really hard to understand at first glance until @olafurpg kindly explained it to me. If I understood him correctly, I believe this will work as expected and I think it's much more readable.

val lastDot = reversedString.indexOfSlice("E200u$") // reversed $u002E = '.'
val reversedString = decoded.reverse
val lastSpace = reversedString.indexOfSlice(" ")
val lastDot = reversedString.indexOfSlice(".")
val startOfWord =
if (lastSpace < lastDot && lastSpace >= 0) lastSpace else lastDot
reversedString.slice(0, startOfWord).reverse

This comment has been minimized.

Copy link
@ckipp01

ckipp01 Nov 29, 2019

Author Member

The only thing I wasn't 100% sure on is here do we need to also encode this again before we pass it into matchesSubCharacters or matches since the entered.toString?

This comment has been minimized.

Copy link
@tgodzik

tgodzik Nov 29, 2019

Collaborator

Not sure either, but might be good to encode it again. Situations like: weird_method@Name

This comment has been minimized.

Copy link
@olafurpg

olafurpg Nov 29, 2019

Member

We always want to fuzzy match against the decoded name, it would be weird to include :: if the user types foo.$colon$col@@

@ckipp01 ckipp01 force-pushed the ckipp01:decode branch from 95b0d72 to a8c3e9f Nov 29, 2019
@tgodzik

This comment has been minimized.

Copy link
Collaborator

tgodzik commented Nov 29, 2019

I really just planned to remove it once we drop support for 2.13.0 and 2.12.8 - it is a bit ugly, but fixed in the compiler itself.

I agree it looks much more readable now, thanks! Although I would be glad to get rid of it altogether 😅

Copy link
Member

olafurpg left a comment

LGTM 👍 This is much clearer!

val lastDot = reversedString.indexOfSlice("E200u$") // reversed $u002E = '.'
val reversedString = decoded.reverse
val lastSpace = reversedString.indexOfSlice(" ")
val lastDot = reversedString.indexOfSlice(".")
val startOfWord =
if (lastSpace < lastDot && lastSpace >= 0) lastSpace else lastDot
reversedString.slice(0, startOfWord).reverse

This comment has been minimized.

Copy link
@olafurpg

olafurpg Nov 29, 2019

Member

We always want to fuzzy match against the decoded name, it would be weird to include :: if the user types foo.$colon$col@@

@olafurpg olafurpg merged commit 00c7aad into scalameta:master Nov 29, 2019
9 checks passed
9 checks passed
Windows unit tests
Details
Linux unit tests
Details
Sbt integration
Details
Maven integration
Details
Gradle integration
Details
Mill integration
Details
Slow tests
Details
Scala cross tests
Details
Scalafmt/Scalacheck/Docs
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.