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

bugfix: Case completions for tuple type #5292

Merged
merged 2 commits into from Nov 2, 2023

Conversation

jkciesluk
Copy link
Member

We shouldn't show case completions for tuple type if query doesn't match label.
Also, sometimes label contained x$1 symbol (eg. (x$1: (Int, Int)) @unchecked scala, which we don't want to show to the user.
I think the simplest way to detect it is just by looking if label contains x$1

connected to the issue found in #5196 (comment)

// Special handle case when selector is a tuple or `FunctionN`.
if definitions.isTupleClass(selectorSym) || definitions.isFunctionClass(
selectorSym
)
then
val selectorTpe = parents.selector.show
val tpeLabel =
if !selectorTpe.contains("x$1") then selectorTpe
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe it'd be better to match on the parents.selector to check when there will be an argument? In case somehow it can have a different name than x$1.

if (patternOnly.isEmpty)
List(
new TextEditMember(
"case () =>",
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you check if this actually shows up on the VS Code side?

Copy link
Member Author

Choose a reason for hiding this comment

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

Label is shown, eg. case (Int, Int) =>

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!

We shouldn't show case completions for tuple type if query doesn't match label.
Also, sometimes label contained `x$1` symbol (eg. `(x$1: (Int, Int)) @unchecked scala`,
which we don't want to show to the user.
I think the simplest way to detect it is just by looking if label contains `x$1`
It was hard to detect we are in `yield @@` or `case (@@)` and this completion was not really usefull,
so it was best to remove it
@tgodzik tgodzik merged commit 0dd2cd8 into scalameta:main Nov 2, 2023
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants