Skip to content

Commit

Permalink
bugfix: Fix off by one error when doing reveal
Browse files Browse the repository at this point in the history
  • Loading branch information
tgodzik committed Nov 8, 2023
1 parent d45eca1 commit b5177c9
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class MetalsTreeViewProvider(
val closestSymbol = occurrences.minBy { occ =>
val startLine = occ.range.fold(Int.MaxValue)(_.startLine)
val distance = math.abs(pos.getLine - startLine)
val isLeading = pos.getLine() > startLine
val isLeading = pos.getLine() >= startLine
(!isLeading, distance)
}
val result =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ object JdkSources {
): Either[NoSourcesAvailable, AbsolutePath] = {
val paths = candidates(userJavaHome)
paths.find(_.isFile) match {
case Some(value) =>
logger.info("Found JDK sources: " + value)
Right(value.dealias)
case Some(value) => Right(value.dealias)
case None => Left(NoSourcesAvailable(paths))
}
}
Expand Down
4 changes: 3 additions & 1 deletion tests/unit/src/test/scala/tests/ScalaToplevelSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -620,10 +620,12 @@ class ScalaToplevelSuite extends BaseSuite {
.map(_.symbol)
.toList
case Toplevel =>
val input = AbsolutePath(Files.createTempFile("mtags", ".java"))
val dir = AbsolutePath(Files.createTempDirectory("mtags"))
val input = dir.resolve("Test.scala")
input.writeText(code)
val obtained = Mtags.topLevelSymbols(input, dialect)
input.delete()
dir.delete()
obtained
}
assertNoDiff(
Expand Down
3 changes: 1 addition & 2 deletions tests/unit/src/test/scala/tests/TreeViewLspSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,7 @@ class TreeViewLspSuite extends BaseLspSuite("tree-view") {
| Text symbol-object
| TextMacros symbol-interface
| Util symbol-object
| File symbol-class
| value symbol-field
| File symbol-object
|""".stripMargin,
)
assertNoDiff(
Expand Down

0 comments on commit b5177c9

Please sign in to comment.