-
Notifications
You must be signed in to change notification settings - Fork 338
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
Conversation
mtags/src/main/scala-3/scala/meta/internal/pc/completions/MatchCaseCompletions.scala
Outdated
Show resolved
Hide resolved
// 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 |
There was a problem hiding this comment.
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 () =>", |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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) =>
mtags/src/main/scala-3/scala/meta/internal/pc/completions/MatchCaseCompletions.scala
Show resolved
Hide resolved
mtags/src/main/scala-3/scala/meta/internal/pc/completions/MatchCaseCompletions.scala
Show resolved
Hide resolved
bd76385
to
e5af5d1
Compare
e5af5d1
to
0ad09aa
Compare
There was a problem hiding this 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
0ad09aa
to
ad44111
Compare
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)