Skip to content

Commit

Permalink
fix: workaround for hover for multi declaraction (Scala 3)
Browse files Browse the repository at this point in the history
  • Loading branch information
kasiaMarek committed Dec 17, 2024
1 parent 1ce512a commit 3a533d4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,13 @@ object MetalsInteractive:
*/
else if head.isInstanceOf[TypeTree] then
enclosingSymbolsWithExpressionType(tail, pos, indexed)
else Nil
else
path match
case (_: ValDef) :: (t : Template) :: _ =>
t.body.collectFirst {
case d: ValDef if d.nameSpan.contains(pos.span) => List((d.symbol, d.symbol.info))
}.getOrElse(Nil)
case _ => Nil
else
val recovered = recoverError(head, indexed)
if recovered.isEmpty then
Expand Down
10 changes: 10 additions & 0 deletions tests/cross/src/test/scala/tests/hover/HoverTermSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -773,4 +773,14 @@ class HoverTermSuite extends BaseHoverSuite {
)
)

check(
"i7012".tag(IgnoreScala2),
"""|object O {
| val x@@x, yy, zz = 1
|}
|""".stripMargin,
"""|
|val xx: Int
|""".stripMargin.hover
)
}

0 comments on commit 3a533d4

Please sign in to comment.