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 3, 2023
1 parent c758243 commit a4558e8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 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
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 a4558e8

Please sign in to comment.