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: [metals] Case completions for tuple type #18751

Merged
merged 1 commit into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -97,25 +97,26 @@ object CaseKeywordCompletion:
selectorSym
)
then
val label =
if patternOnly.isEmpty then s"case ${parents.selector.show} =>"
else parents.selector.show
List(
CompletionValue.CaseKeyword(
selectorSym,
label,
Some(
if patternOnly.isEmpty then
if patternOnly.isEmpty then
val selectorTpe = parents.selector.show
val tpeLabel =
if !selectorTpe.contains("x$1") then selectorTpe
else selector.symbol.info.show
val label = s"case ${tpeLabel} =>"
List(
CompletionValue.CaseKeyword(
selectorSym,
label,
Some(
if config.isCompletionSnippetsEnabled() then "case ($0) =>"
else "case () =>"
else if config.isCompletionSnippetsEnabled() then "($0)"
else "()"
),
Nil,
range = Some(completionPos.toEditRange),
command = config.parameterHintsCommand().asScala
),
Nil,
range = Some(completionPos.toEditRange),
command = config.parameterHintsCommand().asScala,
)
)
)
else Nil
else
val result = ListBuffer.empty[SymbolImport]
val isVisited = mutable.Set.empty[Symbol]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -698,3 +698,27 @@ class CompletionCaseSuite extends BaseCompletionSuite:
|case Dog => test.O.Animal
|""".stripMargin,
)
@Test def `for-comp` =
check(
"""|object A {
| val a = for {
| foo <- List("a", "b", "c")
| abc = println("Print!")
| } yield bar@@
|
|}
|""".stripMargin,
"",
)

@Test def `lambda-case-tuple` =
check(
"""|object A {
| val a = List((1,2)).foreach {
| case (a,b) => println(a)
| case@@
| }
|}
|""".stripMargin,
"case (Int, Int) => scala",
)