Skip to content

Commit

Permalink
bugfix: CompletionPosition inferStart should not crash
Browse files Browse the repository at this point in the history
  • Loading branch information
jkciesluk committed Mar 26, 2024
1 parent 6ef8385 commit 25eeba5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Expand Up @@ -906,7 +906,8 @@ trait Completions { this: MetalsGlobal =>
}
}
}
loop(lastVisitedParentTrees)
val start = loop(lastVisitedParentTrees)
Math.min(start, pos.point)
}

/** Can character form part of an alphanumeric Scala identifier? */
Expand Down
11 changes: 11 additions & 0 deletions tests/cross/src/test/scala/tests/pc/CompletionSuite.scala
Expand Up @@ -2281,4 +2281,15 @@ class CompletionSuite extends BaseCompletionSuite {
""
)

// This checks if inferStart doesn't crash
check(
"infer-correct-start".tag(IgnoreScala3),
"""|object O {
| val alpha = (((hex >> 24) / 0xff & 1@@).toInt
| val red = ((hex >> 16) & 0xff).toInt
|}
|""".stripMargin,
""
)

}

0 comments on commit 25eeba5

Please sign in to comment.