Open
Description
Compiler version
3.6.3
Minimized code
Requesting selection ranges with cursor at @@
below:
object Main extends App {
def x = 12 * (34 + 5@@6)
}
Output
The selection ranges returned are:
56
(good)34 + 56
(good)12 * (34 + 56
(not good)
Expectation
The final selection range should be 12 * (34 + 56)
(with the closing paren).
Here's a patch to produce a test case for this.
diff --git a/presentation-compiler/test/dotty/tools/pc/tests/SelectionRangeSuite.scala b/presentation-compiler/test/dotty/tools/pc/tests/SelectionRangeSuite.scala
index e277a67c46..a600d3e4d7 100644
--- a/presentation-compiler/test/dotty/tools/pc/tests/SelectionRangeSuite.scala
+++ b/presentation-compiler/test/dotty/tools/pc/tests/SelectionRangeSuite.scala
@@ -147,3 +147,21 @@ class SelectionRangeSuite extends BaseSelectionRangeSuite:
|}""".stripMargin
)
)
+
+ @Test def `arithmetic` =
+ check(
+ """|object Main extends App {
+ | def x = 12 * (34 + 5@@6)
+ |}""".stripMargin,
+ List[String](
+ """|object Main extends App {
+ | def x = 12 * (34 + >>region>>56<<region<<)
+ |}""".stripMargin,
+ """|object Main extends App {
+ | def x = 12 * (>>region>>34 + 56<<region<<)
+ |}""".stripMargin,
+ """|object Main extends App {
+ | def x = >>region>>12 * (34 + 56)<<region<<
+ |}""".stripMargin
+ )
+ )
Here's the output of running that test at time of reporting
sbt:scala3> scala3-presentation-compiler/testOnly dotty.tools.pc.tests.SelectionRangeSuite -- dotty.tools.pc.tests.SelectionRangeSuite.arithmetic
[info] Test run dotty.tools.pc.tests.SelectionRangeSuite started
[info] Test dotty.tools.pc.tests.SelectionRangeSuite.arithmetic started
[error] Test dotty.tools.pc.tests.SelectionRangeSuite.arithmetic failed: java.lang.AssertionError:
[error] (+++ Expected, --- Obtained, NO CHANGES)
[error]
[error] object Main extends App {
[error] + def x = >>region>>12 * (34 + 56)<<region<<
[error] - def x = >>region>>12 * (34 + 56<<region<<)
[error] }
[error]
[error] , took 0.286 sec
[info] Test run dotty.tools.pc.tests.SelectionRangeSuite finished: 1 failed, 0 ignored, 1 total, 0.289s
[error] Failed: Total 1, Failed 1, Errors 0, Passed 0
[error] Failed tests:
[error] dotty.tools.pc.tests.SelectionRangeSuite
[error] (scala3-presentation-compiler / Test / testOnly) sbt.TestsFailedException: Tests unsuccessful
[error] Total time: 4 s, completed Feb 9, 2025, 3:48:22 PM