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

fix: correctly sort dependency completions #4804

Merged
merged 1 commit into from Jan 3, 2023
Merged

Conversation

jkciesluk
Copy link
Member

Not all dependencies have version names in the same format, so previous way of sorting was causing exceptions. Now we use basic sorting on String as a fallback

fixes #4799

…mats

Not all dependencies have version names in the same format, so previous way of sorting was causing exceptions.
Now we use basic sorting on String as a fallback
@jkciesluk jkciesluk added bug Something that is making a piece of functionality unusable completions Tickets related to completion functionality labels Jan 3, 2023
Copy link
Contributor

@tgodzik tgodzik left a comment

Choose a reason for hiding this comment

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

LGTM!

Just one comment, but that doesn't need to be handled right now

@@ -105,6 +105,17 @@ class CompletionScalaCliSuite extends BaseCompletionSuite {
"better-tostring",
)

checkEdit(
"alternative-sorting",
"""|//> using lib "co.fs2::fs2-core:@@"
Copy link
Contributor

Choose a reason for hiding this comment

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

Out of curiosity, what was the format that was breaking sorting? Can we handle that in Version.fromString ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Side note: With some libraries like fs2 or cats-effect (can't remember for sure), scala-cli was suggesting an upgrade to sth like 3.3-commithashhere when 3.3.4 was the latest release. Could it be that sort of format?

(I'll report the issue in scala-cli when I see it again)

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, it was caused by format like 3.5-ac5c657, but there are also versions like 3.2.14-75-7902cbf.
In Version we do

val parts = version.split("\\.|-")
val Array(major, minor, patch) = parts.take(3).map(_.toInt)

Which fails trying to do toInt on commithash, so maybe we can handle it there somehow

Copy link
Contributor

Choose a reason for hiding this comment

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

Potentially, we potentially drop any hash we encounter, since we can't get any semantic meaning from it.

@tgodzik tgodzik merged commit 12f2ddd into scalameta:main Jan 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something that is making a piece of functionality unusable completions Tickets related to completion functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Dependency completions don't work for the version part
3 participants